Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to remove quotation marks from a report name within a variable

Posted on 2013-01-03
4
Medium Priority
?
572 Views
Last Modified: 2013-01-03
I am using the string variable ReportName which contains the name of a report "Rpt_MonthlyReport121231".  (The reason for the variable is that the name of the report changes every month.)

It works great when used in the statement:  DoCmd.OpenReport ReportName, acViewPreview, , "HHID=" & ClientNowPrinting  

However it does not work in this statement:  Totalpages = Reports![ReportName].Pages

I discovered the reason is that the latter statement can't accept the QUOTATION MARKS around the name of the report.  (The statement works fine if I simply write Rpt_MonthlyReport in the brackets without quotes)

How can I use the variable and eliminate the quotes?
0
Comment
Question by:David_W_R
[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
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38740712
Try this:

Totalpages = Reports(ReportName).Pages
0
 

Author Closing Comment

by:David_W_R
ID: 38740750
Extend arm, clench fist and pull quickly toward shoulder.  Utter "YES!"
Thanks, mbizup.  Saved SO much time.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38740802
Glad to help out!

BTW, you can do the same with other collections such as forms, controls  etc...


msgbox Forms(strFormName).Controls(strControlName).Value

Or loop through collections getting all elements generically using 'Each':

dim ctl as Control
For Each ctl in Me.Controls
      If ctl.ControlType = actextbox then ctl.BackColor = vbBlue
Next

Open in new window

0
 

Author Comment

by:David_W_R
ID: 38741584
Much appreciated.  I'm making a paper note place next to my keyboard so I can review this format often until it becomes a permanent part of my repertoire.  Could have been very helpful in the past, and I'm sure it'll come in handy again soon.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

636 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