Print records AFTER filtering

R

renold1958

Have a form from which certain records can be filtered. How do I print the
current records after filtering. Report etc is already set up

Much obliged
 
A

Allen Browne

You can apply the Filter of the form as the WhereCondition of the
OpenReport.

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.FilterOn Then
strWhere = Me.Filter
End If

Docmd.OpenReport "Report1", acViewPreview, , strWhere
End Sub

Note that if you have filtered using Filter By Form, and you used text from
one of the drop-down lists in a recent version of Access, this approach will
not work unless you also set up the report so that its source query contains
the same field and table names used in the filter string.
 
R

renold1958

The form, with the data and filter is called FilterOrders, the filter is
called DateFilter on that form. The button to print is called cmdPrint on
that form.The report is called CustomerOrders...so how does that fit in?

Thanks
 
A

Allen Browne

Replace
Me
with:
Forms!FilterOrders
and:
Report1
with
CustomerOrders

If you don't understand VBA code, you may need to use the help file to make
use of the responses you get in these groups.
 
Top