referencing reports via their tag property

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