?
Solved

String variable used as report name

Posted on 2013-02-07
3
Medium Priority
?
343 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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