Retrieving Report Properties

G

Guest

I have a form that will be used to select and print reports. There is an
option group, with Option A or B. There is a combo box next to that.

What the user selects for an option should determine what reports display in
the combobox. The TAG property of the report contains the option.

So what I am trying to do is when the user selects an option, to loop
through the reports in the database and if the Tag property is equal to the
option chosen, populate the combobox with that report caption.

I look through tables using db.tabledefs, but I can't figure out a way to
loop through reports and grab the TAG property. I can loop through and get
the report NAME with currentprojects.allreports(reportnumber).name -- but no
other properties. In fact, when I use
currentprojects.allreports(reportnumber).properties.count, it shows 0.

Is there a way I can do what I'm trying to do, a way of looping through all
the reports and getting the TAG and CAPTION properties? Thanks.
 
A

Allen Browne

Karen, you will have to open the reports in order to get at the properties
of the controls they contain.

Loop through the AllReports collection to get the report names.

Open each one in design view, hidden if you wish:
DoCmd.OpenReport strDoc, acViewDesign, WindowMode:=acHidden

Loop through the contorls on the report:
Dim ctl As Control
For each ctl In Reports(strDoc).Controls

You can then examine ctl.ControlType to get the types you want, and then get
at their Tag and Caption.

Later, close the reports again:
DoCmd.Close acReport, strDoc
 
S

Stefan Hoffmann

hi Karen,
What the user selects for an option should determine what reports display in
the combobox. The TAG property of the report contains the option.
A table containing a option->report relation is a much clearer way to do
this, cause there is no real difference between setting correct tag
values and making the correct entries in such a table.


mfG
--> stefan <--
 
G

Guest

That did it -- thank you!!


Allen Browne said:
Karen, you will have to open the reports in order to get at the properties
of the controls they contain.

Loop through the AllReports collection to get the report names.

Open each one in design view, hidden if you wish:
DoCmd.OpenReport strDoc, acViewDesign, WindowMode:=acHidden

Loop through the contorls on the report:
Dim ctl As Control
For each ctl In Reports(strDoc).Controls

You can then examine ctl.ControlType to get the types you want, and then get
at their Tag and Caption.

Later, close the reports again:
DoCmd.Close acReport, strDoc
 

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