Hi,
The following code loops through all items selected by the end user in a list box and then builds a report based on those selected items. I would like put in a condition that says "if the selected item = Order lead time, then open an alternative report." how would I go about writing this in?
I started witht he following but it does not work.
Example of what I tried:
If (varItem) = "Order lead time"
DoCmd.OpenReport "rpt-Backorders", acViewPreview
Example of the code:
Private Sub cmdPreview_Click()
On Error GoTo Err_Handler
Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDelim = """"
strDoc = "rpt-OrderIssues"
With Me.lstCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With
The following code loops through all items selected by the end user in a list box and then builds a report based on those selected items. I would like put in a condition that says "if the selected item = Order lead time, then open an alternative report." how would I go about writing this in?
I started witht he following but it does not work.
Example of what I tried:
If (varItem) = "Order lead time"
DoCmd.OpenReport "rpt-Backorders", acViewPreview
Example of the code:
Private Sub cmdPreview_Click()
On Error GoTo Err_Handler
Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDelim = """"
strDoc = "rpt-OrderIssues"
With Me.lstCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With