How do I iterate through report sections in VBA?

C

cbfuk

Is there a way to find out which sections are defined in a report, and
to iterate through them? There doesn't seem to be a "Sections"
collection, and accessing any section with rpt.Section() appears to
require knowing in advance that it exists! I need to make some code
generic and able to find out for itself, but can't see how.
 
A

Allen Browne

Just refer to the section by number, and use error-correction to recover
from the sections that do not exit.

For the numbers, you can use the AcSection constants, e.g. acDetail,
acFooter, acGroupLevel1Footer, e.g. the highest level group header would be:
Me.Sections(acGroupLevel1Header)

There's only a finite number number of header/footers allowed: about 10 from
memory.

Of course, there may be a group 1 footer but no header, and a group 2 header
but no footer, and so on.
 
C

cbfuk

I was afraid it might have to be something as crude as that! I also
wasn't sure how many sections were theoretically possible - the online
help merely suggests "more than 9". Thanks for your help.
 

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