Filter by Selection/Filter by Form Report

  • Thread starter Thread starter Alan
  • Start date Start date
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.
 
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
 
Back
Top