Skipping Report Sections

D

DaleMatt

I need to skip report sections while not advancing the record in a report.

As an example:
Record 1: Print report header and detail sections. Skip the footer.
Record 2: Skip the header and detail sections. Print the footer.

Record 3: Skip the header and detail sections. Print the footer. THEN,
while not advancing the record off of Record 3, print the header and detail
sections.

(Explaining why I want to do this would just be confusing; trust me, though,
this particular report and this dataset requires it.)

The report would look like this:

Header: Record 1
Detail: Record 1
Footer: Record 2
Footer: Record 3
Header: Record 3
Detail: Record 3

Using the On Format event I'm able to handle records 1 and 2. Record 3 is
giving me a problem: how do you skip sections and go back to the Header
section without advancing the record?

Any ideas would be greatly appreciated...
 
A

Allen Browne

You can repeat a record by using NextRecord, MoveLayout, and PrintSection.

These are runtime properties of the report: you cannot see them in the
Properties box, but you can use:
Me.NextRecord = False

You can suppress a section by setting its Visible property to No in its
Format event. By setting NextRecord to False, you can go back and repeat a
record, but you cannot go back and repeat headers. (Perhaps you could use a
subreport to manipulate the lower level detail independently.)

Trying to manipulate the report events like that yields poor results IME.
You get the wrong results if the report runs into multiple pages and you
print only the later pages, becuase the events don't fire for the pages that
were skipped and so the content of page 4 is different to what you would get
if you printed the entire report including page 4. You will also find that
Access gets confused and gives wrong totals and counts - even confusing
things like "Page 9 of 7." Further, the report events don't fire at all in
Access 2007 when you use the new layouts (Report view and Layout view), so
what the user sees is nothing like what you intended.

There is probably a better way to design the report. At worst, you could
create a temporary table and programmatically append records for the right
stuff you want to show on the report.
 
D

DaleMatt

Allen,

Thank you for your detailed reply. The properties you mentioned were very
helpful.

Your warning about manipulating the report this way is acknowledged: I have
a feeling this is going to "end badly." My alternative is to make a
significant change to the report query which will make it run longer but
would probably avoid the other problems you mentioned.

Again, thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top