I am trying to filter a report based on a field boolean value. I have a combo box on my form called cboTardy. The drop down's row source includes ("Excused";"Unexcused";"Ex
cused & Unexecused") and is unbound. I would like to filter my report based on the combo box selection. If "Excused" is selected the report will only display records with the 'true' value (-1) in the tblStdTardyExcused field. If the user selects "Unexcused" then filter those records with a 'false' value (0) and if both "Excused & Unexcused" is select the report should ignore any tblStdTardyExcused filter (or allow either value) and tack on only the date filter.
I tried doing this (see code) but am getting an error message.
Private Sub cmdRunTardyReport_Click()
On Error GoTo Err_cmdPrintReport_Click
Dim iViewMode As Integer
Dim stDocName As String
Dim strFilter As String
stDocName = "rptStudentTardy"
If Not IsNull(Me![cboTardy]) Then
If Me![cboTardy] = "Excused" Then
strWhere = "[tblStdTardyExcused] = '" & True & "'"
ElseIf Me![cboTardy] = "Unexcused" Then
strWhere = "[tblStdTardyExcused] = '" & False & "'"
strWhere = ""
MsgBox "Please select a value from the dropdown " & vbNewLine & "box before printing this report.", vbCritical, "Value Not Selected"
If IsDate(Me.txtStartDate) And IsDate(Me.txtEndDate) Then
strWhere = strWhere & " And [tblStdTardyDate] Between #" & Me.txtStartDate & "# and #" & Me.txtEndDate & "#"
strWhere = strWhere & "[tblStdTardyDate] = #" & Date & "#"
Select Case MsgBox("Preview report before printing?", vbQuestion Or vbYesNoCancel, "Select Print Method")
iViewMode = acViewPreview
iViewMode = acViewNormal
'Close the report if already open: otherwise it won't filter properly.
If CurrentProject.AllReports(stDocName).IsLoaded Then
DoCmd.Close acReport, stDocName
DoCmd.OpenReport stDocName, iViewMode, , strWhere