Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have a report pick up the filter from a second form

Status
Not open for further replies.

McLiguori

Technical User
Mar 27, 2003
90
IT
I am using Access 2007. I have a form 'Personnel' on which I have buttons to print reports. The buttons open up a modular form, i.e. ageinstructios, in which the user fill in some of the parameters fo the report, i.e. date to which to calculate the age, status, and group. On the modular form, I then have a button that opens the report in preview. The query on which the report is based picks up the parameters from the modular form and all works well.

However, I would like the report to pick up the current Filter from the 'Personnel' form. Since I am calling the report from the modular form, when I try:

DoCmd.OpenReport "AgeReport", A_PREVIEW, , Me.Filter

in the 'on click' of the button that opens the report, it does not pick up the filter from my 'personnel' form, but rather, I think, from the modular form from which it is being called.

How can I open the report from the modular form, but have it pick up the Filter from the 'Personnel' form? I am guessing the 'Me.Filter' part of the command has to change. I have tried a number of things, but nothing has worked.

Thanks for any help you can give.

McLigs
 
I would write some code that checks to see if there is a filter and it is on. Perhaps something like:
Code:
Dim strFilter As String
If Forms!frmPersonnel.Filter & "" <> "" AND _
      Forms!frmPersonnel.FilterOn = True Then
   strFilter =Forms!frmPersonnel.Filter
End If
DoCmd.OpenReport "AgeReport", A_PREVIEW, , strFilter

Duane
Hook'D on Access
MS Access MVP
 
Thanks Duane,
I couldn't get your suggestion to work (probably doing something wrong!), but it gave me the lead I needed.
I ended up making the record source of the module the same as the personnel form. Then in the module's 'open report' button I included the following:

Me.Filter = Forms!Personnel.Filter
DoCmd.OpenReport "Age", A_PREVIEW, , Me.Filter

That seemed to do the trick.

Thanks for getting me there!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top