Question : Access 2007 VBA Report onFormat ignored on open

If I create ANY report in ANY database the OnFormat event in ANY section on the report is ignored when I open the report in report view.

If I right click and open the report in print preview the onformat is processed. If I then right click again and chose report format the onFromat has also been processed.

This took me about an hour to work out  - I couldn't believe that my onformat statements were wrong! In the end the VBA just set a text field to .visible = false and it still showed up - unitl I did a print preview.

Is this a bug in Access 2007 or am I missing something? Could some one try it out - just crate a v simple talbe and an outomatic report and set the onformat  event in say the detail section to field.visible=false.




Answer : Access 2007 VBA Report onFormat ignored on open

Okay ... I get the same behavior in Report view as what you report. If I actually Print the report, however, my events do fire.

Here's what MS has to say about Report view:

By using Report view, you can browse an accurate rendering of your report without having to print or display it in Print Preview. To focus on certain records, use the filter feature, or use a Find operation to search for matching text. You can use the Copy command to copy text to the Clipboard, or click the active hyperlinks displayed in your report to follow a link in your browser.

From here: http://office.microsoft.com/en-us/access/HA100241851033.aspx

It's somewhat vague as to what Report View is actually supposed to do, but appears to be firing somewhere in front of Print Preview. You could disable ReportView for your reports, thereby forcing users to either Print or Preview, both of which would fire your code. From my slim readings, it appears the new Report view is intended to allow users to customize the DATA they wish to see on their report, by using the Filter/Find features mentioned above, and thus wouldn't necessarily fire any events ... but if you're using VBA to format/customize your report and/or data, you'll likely need to use a different event (like the Page, Load or Print events).
Random Solutions  
 
programming4us programming4us