Open a second report and apply the first report's user filter

manderson_zim

New member
Local time
Today, 02:57
Joined
Mar 31, 2011
Messages
7
I have a report (rptStudy) which a user can filter by means of several text boxes in a form (frmSearch). The filter criteria is entered into the form which then opens the report, applies the filter, and closes the form. Works great. Here is my problem: I would like to have a command button on the report (cmdOpen) which opens a second report (rptStudy2) while keeping the same filter applied to the second report.

I'm sure the solution is easy, but I cannot find it anywhere! Thanks.
 
One way to do what you want is to read the current Record Source of the current report and assing that value to a variable with the following code:

Code:
Dim strCurRecSource as string
strCurRecSource = Me.RecordSource

Then you can use the variable to assign this as the record source of your next report.

Assumeing that your first report has an sql statement as its record source, another way would be to update a query using the record source of the fisrt report and then have the second report use the updated query as its record source. YOu could do this with code like:

Code:
CurrentDb.QueryDefs("NameOfYourQuery").Sql = Me.RecordSource

Replace the "NameOfYourQuery" with the actual name of the existing query you want to update. The line of code above will update the definition of the query you provide the name of to be the same as the record source of the first report.
 

Users who are viewing this thread

Back
Top Bottom