referencing reports via their tag property

G

Guest

I'm able to open a report from a text box list that contains the name of the
report in a form with
DoCmd.OpenReport Me.ActiveControl, acViewPreview
but I rather not reference them by name. I want to be able to open the
report via their tag property but can'ts seem to frind a way to reference all
report defintions (like the TableDefs in DAO).
I want to say:
For each report in ReportDefs
if report.tag = ReportNumber then
DoCmd.OpenReport report, acViewPreview

Any suggestions on how to refer to all reports; do they need to be opened
first or something?
Thanks
 
F

fredg

I'm able to open a report from a text box list that contains the name of the
report in a form with
DoCmd.OpenReport Me.ActiveControl, acViewPreview
but I rather not reference them by name. I want to be able to open the
report via their tag property but can'ts seem to frind a way to reference all
report defintions (like the TableDefs in DAO).
I want to say:
For each report in ReportDefs
if report.tag = ReportNumber then
DoCmd.OpenReport report, acViewPreview

Any suggestions on how to refer to all reports; do they need to be opened
first or something?
Thanks

Let's assume the report's Tag property value is 123.

Public Sub GetTagProp()
Dim db As DAO.Database
Dim doc As Document
Set db = CurrentDb
For Each doc In db.Containers("reports").Documents
DoCmd.OpenReport doc.Name, acViewDesign, , , acHidden
If Reports(doc.Name).Tag = "123" Then
DoCmd.OpenReport doc.Name, acViewPreview
Else
DoCmd.Close acReport, doc.Name, acSaveNo
End If
Next doc
End Sub
 

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