troubleshooting Question

Multi Select List Box - Validate Users Selected Values before Processing

Avatar of creativefusion
creativefusionFlag for Australia asked on
Microsoft Access
6 Comments1 Solution432 ViewsLast Modified:
All,

I have a multi-select listbox containing records from a table/query.

My user can select any number of lines and mark them as processed. However, I need to perform a validation of the selected lines to ensure none of them contain a status of 9.

If 1 or more lines selected contain a status of 9, I want to stop the code from running and ask the user to review the lines they have selected again before trying again.

Here is my current code:

Private Sub Command3_Click()
On Error GoTo Err_Handler
'PROCESSING ALL THE LINES SELECTED BY THE USER

Dim uCode As Integer
Dim Status9Test As Boolean

'Column where status resides is column(8)

'Checking to see if user selected something
    With Me.lstReconBillerLoads
   
        If .ItemsSelected.Count = 0 Then
            'No record found prompt
            msg = "Could not find any lines for processing." & vbCrLf & "" & vbCrLf & _
            "Please select which lines you wish to process from the list."
            title = "No lines selected"
            style = vbOKOnly + vbInformation
            response = MsgBox(msg, style, title)
            Me.lstReconBillerLoads.SetFocus
        Else
            'check to see if the user has selected any lines with a status 9
            If Status9Test = True Then
                msg = "Either one or more of the lines you have selected contain a status code of 9 and cannot be processed." & vbCrLf & "" & vbCrLf & _
                "Please review which lines you have selected and try again."
                title = "Status 9 found"
                style = vbOKOnly + vbInformation
                response = MsgBox(msg, style, title)
                Me.lstReconBillerLoads.SetFocus
            Else
                'okay to proceed
                msg = "All of the lines you selected can be processed."
                title = "Status 9 not found"
                style = vbOKOnly + vbInformation
                response = MsgBox(msg, style, title)
                Me.lstReconBillerLoads.SetFocus
            End If
        End If
    End With

ErrorHandlerExit:
   Exit Sub

Err_Handler:
   If Err.Number = 0 Then
      Resume ErrorHandlerExit
   Else
    msg = "An unexpected error has been detected" & Chr(13) & _
    "Description is: " & Err.Number & ", " & Err.Description & Chr(13) & _
    "Please note the above details before contacting DLD support."
    title = "Support error messaging"
    style = vbOKOnly + vbInformation
    response = MsgBox(msg, style, title)
      Resume ErrorHandlerExit
   End If
End Sub



Can anyone help me with this?

CF
Database1.accdb
ASKER CERTIFIED SOLUTION
creativefusion

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros