Set filter of form and then print report

S

SAC

Access 2000

I'd like to be able to set a filter on a from and click a button to print a
report based on the filtered records only.

Any ideas?

Thanks.
 
A

Allen Browne

Put something like this into the Click event procedure of your command
button:

Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End IF
DoCmd.OpenReport "Report1", acViewPreview, , strWhere
End Sub

If the form is performing filtering based on fields in the lookup tables of
the combos, you will need the matching tables in the RecordSource of your
report for that to work.
 
S

SAC

Excellent! Thanks!

Allen Browne said:
Put something like this into the Click event procedure of your command
button:

Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End IF
DoCmd.OpenReport "Report1", acViewPreview, , strWhere
End Sub

If the form is performing filtering based on fields in the lookup tables of
the combos, you will need the matching tables in the RecordSource of your
report for that to work.
 
Top