Filter by Selection/Filter by Form Report

A

Alan

I have a form where I want to use the 'filter by selection' or 'filter by
form' functions. These work fine for the form. I have a button on this
form to report the data. How do I reference the data source of the report
so that it will use the filtered data from the report. If I make the Form
and the Report reference the same query as the data source, the report
contains all the data that was available to the form, not the filtered
subset.

As you can tell, I am new to Access, but have been doing app development in
other languages for many years.
 
A

Allen Browne

Use the Filter property of the form in the WhereCondition of the OpenReport.

Your command button will need this in its Click event procedure:

Dim strWhere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.FilterOn Then 'Use the same filter, if it's switched on.
strWhere = Me.Filter
End If
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top