[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

String variable used as report name

Posted on 2013-02-07
3
Medium Priority
?
344 Views
Last Modified: 2013-02-07
I have a list of subreport names in a table. The user wants to be able to see many reports on one. I created a form with the report names and created one report that contains many subreports. The reports the user wants to see are made visible. I need to make the subreports visible using the variable. I am trying to move the report name to a string variable and call it this way:

dim rptName as string
dim rs as dao.recordset
dim cd as dao.database
dim strSQL as string
set cd = currentDB
strSQL = "Select ReportName from ReportList"
set rs = cd.openrecordset(strSQL)

For i = 1 To rs.RecordCount
  rptName = rs!ReportName
  Reports(rptName).Visible = False
rs.MoveNext
Next

I get an error saying that the report is misspelled or refers to a report that doesn't exist. The name of the report is correct but it has single quotes around it which may be the problem.
0
Comment
Question by:LeLeBrown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 38865648
That is because they are no longer "reports" if they are embedded in another report, they are subreport controls.  Try:

For i = 1 To rs.RecordCount
   rptName = rs!ReportName
   Reports(MainReportName).Controls(rptName).Visible = False
   rs.MoveNext
Next

This of course assumes that the subreport controls in you main report all have their Name property set to the name of the form that is the sourceObject for that control.
0
 

Author Closing Comment

by:LeLeBrown
ID: 38865683
That worked. Thanks!!
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 38865732
You are welcome, glad I could help.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question