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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refer to report name held in variable

Status
Not open for further replies.

bmc1234

Programmer
Jul 21, 2005
50
US
I am trying to refer to a report from some code attached to a form. I'm using the normal method of reports!reportname. My problem is that I want reportname to be a string variable holding the name of the report. When I do that it gives me a type mismatch error at runtime. Does anybody know how to refer to a report using a variable for report name? Thanks.
 
No, that didn't work.

Let me elaborate in case the error is at a different point on the line...
The full line is this:
reports!reportName!StatusDate.visible = False

I'm trying to change a property of a control on the report depending on what is chosen on the form.
 
Hi!

Dim strReport As String

strReport = "YourReportName"

Reports(strReport)

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
How are ya bmc1234 . . .

. . . and this:
Code:
[blue]   reports([i]VariableName[/i])!StatusDate.visible = False[/blue]

Calvin.gif
See Ya! . . . . . .
 
This doesn't seem to be working. It still gives me the type mismatch error. I looked at the docs in access's help and it looks like it wants that variable to be an integer referencing the index of the report within a collection rather than a string.
 
Post your code. What Aceman suggests is the common approach. You can use an index, but both the named index and the integer index work.

reports(1) or reports("myReportName") or reports(variable)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top