How do I iterate through report sections in VBA?

  • Thread starter Thread starter cbfuk
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top