Full Version: Applying A Filter Then Printing
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
Wood Butcher
I have the same report that runs for different users. So what I'm trying to do is put a button out there that will basically run thru and change the report header and data returned for each user.

The report header part works fine, but the applied filter part isn't working at all...I"m getting all the data!

DoCmd.OpenReport "Location", acViewDesign, , "[User1] = True"
DoCmd.SetProperty "label166", acPropertyCaption, "User1's Daily Report"
DoCmd.PrintOut

DoCmd.OpenReport "Location", acViewDesign, , "[User2] = True"
DoCmd.SetProperty "label166", acPropertyCaption, "User2's Daily Report"
DoCmd.PrintOut

Etc, etc....

I have a field for each user in the query and on the report (hidden on the report) as a yes/no field. So if [User1] is checked they only get the records that they are checked off on.

HELP!
theDBguy
Hi,

What version of Access are you using? Sounds like you may have a "repeating group" in your table which is usually a sign of bad design. We might be able to suggest another way to accomplish what you want if you could describe your table structure for us.

Just my 2 cents...
John Spencer
Instead of opening the report in design view, open the report to preview or print. The criteria string you set in design view is temporary and will not get used when you switch to preview or print. Use the OpenArgs argument to pass the label change

DoCmd.OpenReport "Location", acViewPreview, , "[User1] = True",,"USER 1 Report"

Then in the open event of the form use code to set the caption of the label to the value of the report's open args property
Me.Label166.Caption = Me.OpenArgs & ""


This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.