Assuming you've used a Boolean (Yes/Mo) Close field in the report's
underlying table, you can cover all bases by using a single report
which as designed shows all cases, but filtering it by opening the
report from a simple unbound dialogue form with three controls, an
option group in which you can select Open, Closed or All Cases, a
check box which if checked sends the report to the printer rather than
the screen, and a button to open the report.
Name the option group fraCaseTypes, the check box chkPrinter and the
button cmdOpenReport. Use the control wizard to set up the option
group and give it three option buttons, with values 1, 2 and 3
corresponding to Open, Closed or All Cases. In the button's Click
event procedure put the following code:
Const REPORTNAME = "YourReportName"
Dim intView As Integer
Dim strCriteria As String
' is report to be printed or previewed?
Select Case Me.chkPrinter
Case True
intView = acViewNormal
Case Else
intView = acViewPreview
End Select
' what case type are to be included?
Select Case Me.fraCaseTypes
Case 1 ' open cases
strCriteria = "Closed = False"
Case 2
strCriteria = "Closed = True"
Case Else
strCriteria = ""
End Select
' open report
DoCmd.OpenReport REPORTNAME, _
View:=intView, _
WhereCondition:=strCriteria
To do this select the button in form design view and open its
properties sheet if its not already open. Then select the On Click
event property in the properties sheet. Click on the 'build' button;
that's the one on the right with 3 dots. Select 'Code Builder' in the
dialogue, and click OK. The VBA window will open at the event
procedure with the first and last lines already in place. Enter the
lines of code (you can copy and paste from above) between these two
existing lines.
Ken Sheridan
Stafford, England