Output to PDF doesn't "run" .Visible

chuckcoleman

Registered User.
Local time
Today, 08:26
Joined
Aug 20, 2010
Messages
380
Hi, I have a report that has on the "On Load" event some code that makes a text box visible or not based on some criteria. It works perfectly when you open the report using Print Preview. When I click on a Command Button that runs code and then exports the report to a PDF, the .visible doesn't work for the text box. The text box is not shown in the PDF even though the criteria on the form was there when I clicked on the Command Button. My guess is that because the report isn't opened, (loaded), the code never runs to make the text box visible or not.

Any ideas?

Thanks, Chuck
 
You can use OpenReport to open the report, you can make it invisible. Then export with OutputTo, then close the report.
 
Just adding another thought

I rarely use Access reports but I think I have heard that there is a Format or OnFormat event - and this might be the event you want to use for things that must be reflected in a printout.
 
To programmatically manipulate the visibility of controls in reports you need to use the Format or Print events of the section containing the specific controls. Alternatively you can try to do it using conditional formatting (to make a control content invisible create a formatting rule to set its fore colour the same as its backcolour).
Cheers,
 
All, thank you. The easy solution was to move my code from On Load to the Format section of a Section. That worked.

Thank you!

Chuck
 
Just as a follow-up, turns out that reports have TWO event paths. If you are displaying the report, you use OnFormat. If you are printing the report (which might be inferred from being in Print Preview mode), you use OnPrint. They are mutually exclusive.
 
The_Doc_Man, For What It's Worth, I used the On Format event in the Report Footer, and it worked.
 
Just as a follow-up, turns out that reports have TWO event paths. If you are displaying the report, you use OnFormat. If you are printing the report (which might be inferred from being in Print Preview mode), you use OnPrint. They are mutually exclusive.

In my experience, it's Report view that differs from Preview and Print.
 

Users who are viewing this thread

Back
Top Bottom