Can I run the format event code for each report in a multiple record set?

tstoneami

Registered User.
Local time
Today, 13:35
Joined
Aug 5, 2013
Messages
22
I have a post already here:http://www.access-programmers.co.uk...un+on+format+event+for+each+record+for+report

Which has a very simplified example of what I am trying to do.

Essentially it seems like the format event fires only once with a docmd that has a where clause. If I print a single report it is perfect! Example one in the above post has a subreport, example 2 its very simply incorporated into the main report with no sub report. I really need a solution!
 
The Format event fires for each record in the detail section. The format event for other sections fires each time that section needs to print.

In fact, the Format event may fire multiple times for the same record and if you have code in the Format event, you need to be aware of this. For example, Access Formats a record and tries to print it but there isn't enough room on the page so it runs the Retreat event. then it runs the events needed to format a new page and reruns the Format event for the record it couldn't print before.
 
I read about the retreat yesterday when attempting to find a solution. I also read that the format event is supposed to fire for each record, but even as it does - it seems to only point to a single record when running the logic. In other words, the if logic runs on the fields based on the field content from another record.

I did match type, and my where actually does appear to be working - is it possible the where worked for the initial generation of reports, but fails after when the on format code is executing?
 
The code in reports runs ONLY when the report is opened in print preview or normal view which is "send directly to printer". Report view and layout view do not run the code.
I also read that the format event is supposed to fire for each record
It does.
it seems to only point to a single record when running the logic
That is correct. If your code needs to reference a previous record, you need to save the values in a report level variable.

Creating a report is essentially a sequential process. Access opens the recordset and calls the report header events and then the page header events. If you have any grouping levels, those events are called next. Then the detail event. Access reads the next record and determines if there is a group break. If not, it runs the detail event and reads the next record. In the Print event of each event, Access determines if there is space left on the current page to print the section it is working on. If not, it runs the retreat event and then runs the page footer events. Then it determines if it needs to repeat any group headers on the next page. Then it prints the record that caused the page break and reads the next record. Under no condition is there more than a single active record.
 
The code in reports runs ONLY when the report is opened in print preview or normal view which is "send directly to printer". Report view and layout view do not run the code.
Quote:>>>>I've only ever ran it this way. I also tried printing it. - shows the same data that is on the preview.
 
each (most) section has a format event and a print event.

some things need to go in the print, not the format and vice versa

maybe you are running the format event not in the detail section, but in one of the other sections, so it is not checking every record.


(pat said this in #2)
 
>>>maybe you are running the format event not in the detail section, but in one of the other sections, so it is not checking every record.

Most definately not.

I am tossing around installing a hotfix I found where it states that the filter doesn't run properly in MS Access 2010 SP1.

If you have a second, maybe you can install the demo I attached. Also, I have tried what pat said regarding matching the data types in the master child fields.

What baffles me is that it totally pulls all the right data for all the reports, its just aht the logic fails in the report form in some fashion.
 
Hi,

Well, I set a breakpoint in the format code, and when it paused I looked at the name it was seeing for the person in the record. It was actually showing the name from another report - the third instead of the first which it immediately stopped on.

So, when I print multiple reports, the format code is definately looking at the wrong record to act upon. What could be happening? The format event is not pointing at the current record!
 
Are you absolutely certain that your code is in the format event for the DETAIL section. EVERY section has a format event. If you put the code in the wrong section, it won't fire for every record. Please post the entire code module for the report.
 
I have someone with 2013 verifying this issue now...I have been expecting it to be something I fundamentally don't know about but it isn't the case so far.
 

Users who are viewing this thread

Back
Top Bottom