Fritz Paul
asked on
Step through the sections in a report
I want to address each section in a report with VBA, which is already open in design mode.
I specifically want to use the For Each code.
What I've got now is
Dim scn As Section
For Each scn In [Reports]![rptProfiles1] ' "rptProfiles1" is the report name
Debug.Print Reports!rptProfiles1.Secti on(scn).[N ame], Reports!rptProfiles1.Secti on(scn).[H eight]
Next
I just cannot get this section one to work.
However, what is working for the same report is
Dim ctl As Control
For Each ctl In Reports!rptProfiles1
Debug.Print ctl.Name, ctl.Height
Next
Please help with the section code
I specifically want to use the For Each code.
What I've got now is
Dim scn As Section
For Each scn In [Reports]![rptProfiles1] ' "rptProfiles1" is the report name
Debug.Print Reports!rptProfiles1.Secti
Next
I just cannot get this section one to work.
However, what is working for the same report is
Dim ctl As Control
For Each ctl In Reports!rptProfiles1
Debug.Print ctl.Name, ctl.Height
Next
Please help with the section code
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
I wanted to specifically use
For Each section in report
......
Next
Because I can not get it to work,
But the solution given is neat and easy.
I wanted to specifically use
For Each section in report
......
Next
Because I can not get it to work,
But the solution given is neat and easy.
As borki said, to be able to use ' for each section in...' there has to be a Sections collection object. But there is no such collection so you have to use the section array.
You can then address the a single object using an integer or a predefined constant such as acDetail (0).
HTH