Using Filtered Form to Filter Report

  • Thread starter Thread starter Al Camp
  • Start date Start date
A

Al Camp

I have just started converting an Approach application to Access 2003.
The old app had the ability to use the recordset from a filtered form as the
recordset for the report.

If the recordset for the form was "all records", and the report called up,
only that unique record would be reported on.
But, if the user then filters the form (say... by city) and ends up with 100
records, the same report displays all 100 records.

I'm familiar with using a single or multiple "live" form values to filter a
report "on the fly", or... using parameter queries to allow more reporting
flexibility, but...

Is there some way to use the "active recordset" of an open form as the "on
the fly" RecordSource of a report?

Thanks in advance,
Al Camp
 
Folks,
I have to tweak this question a bit.
On further investigation, it appears as if the Approach application that
I'm trying to convert was not really doing what the user claimed it was. My
setup in the first post is incorrect.
Please disregard my previous setup, and let me just ask this...

Can a report somehow use the recordset that an open form is using at the
time as it's recordsource?

Or, perhaps there is a way that the report can utilize the .Filter
property of an active form as a "criteria" for its own
recordsource query/table?

Thanks for any assistance,
Al Camp
 
I haven't tested, but assuming that the form is open, you can retrieve its
Filter in code as something like Forms!MyFormName.Filter

You could get the Form's filter in your Report's Open event and set the
Report's filter.
 
Thanks Doug,
I'll be working that up very soon, and it sounds like it should fly.
Thanks for letting me know I was on the right track with trying to use
the form's filter.
I'll try to get back to you on this...
Thanks again,
Al Camp
 
You might want to try use code like (untested):

Dim strWhere as String
If Me.FilterOn = True Then
strWhere = Me.Filter
End If
DoCmd.OpenReport "rptMyReport", acPreview, , strWhere
 
Back
Top