Data on Preview Missing on Print

Privateer

Registered User.
Local time
Today, 07:57
Joined
Aug 16, 2011
Messages
193
I am getting two different results when I preview or print a report. When I preview a report the report title and page title are populated with the strings I built and assigned to global variables. In the report load event the GVs are assigned to the text boxes. Everything works great. If I hit the print icon while previewing the report, those text boxes are populated with the right strings. The problem is I have the option to send the report directly to the printer without previewing it, using the code below.

Code:
DoCmd.OpenReport Report, acViewNormal, , , acHidden

When this is executed, the report title and page title text boxes are blank. I have put a debug.print (the 3 GVs) in the load event and it spits out the three strings, but the actual printout has no titles. The bound data always prints, but these unbound text boxes fail. I have even copied the string assignment to the open event and that did not work. Anyway, I would be grateful for any help or suggestions. Windows 7 Office 2010.
 
You should assign data to unbound textboxes in the _Format() event handler of the section in which said textboxes appear. Printing is very much oriented around report sections, and sections that aren't currently printing don't really exist yet, and sections that have been printed are discarded. This is a little different in preview, when the whole report is somewhat artificially preserved so you can view the whole thing on screen. In fact, each report section is formatted completely independently, and with little regard for the other sections, and therefore data assignments to unbound textboxes should occur at that time.

Also, you don't need acHidden for acViewNormal, but I don't think that's the problem.
 
MarkK, Wow, you were spot on. I put the report title in the report header format event and the other two in the page header format event and the strings showed up. Thank you very much for the quick response and the report lesson.
 
Yeah, you bet. Your description of the problem--how it fails, when it fails, when it works as expected/desired--was very clear. Makes it much easier to troubleshoot.
Cheers,
 

Users who are viewing this thread

Back
Top Bottom