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
Solved

String variable used as report name

Posted on 2013-02-07
3
339 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
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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 47

Expert Comment

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

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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 …

790 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