Hello, I need help with the following code which is working perfectly. However, I'm unable to add the Where clause which will enable the users to filter reports by year and/or by month.
These 2 criterias are listed in 2 unbound multiselect value listboxes (lstYear and lstMonth) and should be optional.
Thank you!
Chantal
Private Sub cmdPreview_Click()
On Error GoTo cmdPreview_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, acViewPreview
End If
Exit Sub
cmdPreview_ClickErr:
'Select Case Err.Number
' MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
'Case Else
' MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdPreview_Click()"
'End Select
Resume Next
End Sub
Private Sub cmdPrint_Click()
On Error GoTo cmdPrint_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, acViewNormal
End If
Exit Sub
cmdPrint_ClickErr:
'Select Case Err.Number
' MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
'Case Else
' MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdPrint_Click()"
'End Select
Resume Next
End Sub
These 2 criterias are listed in 2 unbound multiselect value listboxes (lstYear and lstMonth) and should be optional.
Thank you!
Chantal
Private Sub cmdPreview_Click()
On Error GoTo cmdPreview_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, acViewPreview
End If
Exit Sub
cmdPreview_ClickErr:
'Select Case Err.Number
' MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
'Case Else
' MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdPreview_Click()"
'End Select
Resume Next
End Sub
Private Sub cmdPrint_Click()
On Error GoTo cmdPrint_ClickErr
If Not IsNull(Me.lstReports) Then
DoCmd.OpenReport Me.lstReports, acViewNormal
End If
Exit Sub
cmdPrint_ClickErr:
'Select Case Err.Number
' MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
'Case Else
' MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdPrint_Click()"
'End Select
Resume Next
End Sub