I would like to filter Report: DQC by an OPTIONAL date range (which I have done with the code below). I would also like to filter it by and OPTIONAL combo box that self populates from my table with PEBLO names. I have gotten the combo box to self populate, but do not know how to add it into the VB. Combo Box Name: Combo27
Private Sub Command29_Click()
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"
strReport = "DQC"
strDateField = "[Date]"
lngView = acViewPreview
If IsDate(Me.Text22) Then
strWhere = "(" & strDateField & " >= " & Format(Me.Text22, strcJetDate) & ")"
End If
If IsDate(Me.Text24) Then
If strWhere <> vbNullString Then
strWhere = strWhere & " AND "
End If
strWhere = strWhere & "(" & strDateField & " < " & Format(Me.Text24 + 1, strcJetDate) & ")"
End If
If CurrentProject.AllReports(strReport).IsLoaded Then
DoCmd.Close acReport, strReport
End If
'Debug.Print strWhere 'Remove the single quote from the start of this line for debugging purposes.
DoCmd.OpenReport strReport, lngView, , strWhere
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Cannot open report"
End If
Resume Exit_Handler
End Sub
Private Sub RUN_Click()
End Sub