Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Explicit References 1

Status
Not open for further replies.

lewatkin

Programmer
Mar 8, 2002
91
US
Hi,

When you are referencing an Access object (form, report) etc. in a code module outside the object you are referencing, I understand that you have to reference it explicitly - reports!rptMyReport etc. What I am wondering is this, can you pass a report name as a variable to this explicit reference?

Here's the scoop. I am using a form to filter an open report. I got the info from the Knowledge Base. The code in the form explicitly references a particular report. The issue is, I want to be able to use 1 Filter form for 10 different reports and not have 10 different forms. I am currently housing the information for the form in a table and am populating it depending on which report you want to see. But the code fails when it hits the Reports!MyRpt variable stating that MyRpt cannot be found in the Reports collection. MyRpt is the variable (Dim MyRpt as String) that holds the report name. But I cannot figure out how to pass the report name as a variable. Any Ideas??

Lee
 
Hi,

Dim MyReport As String

MyReport = "rptBalance"
DoCmd.OpenReport MyReport, acViewPreview

'Use this syntax instead of reports!MyRpt
Debug.Print Reports(MyReport).Caption

Have a good one!
BK
 
BlackKnight,

THANK YOU so much for your assistance!!! Works like a charm!!!

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top