Solved

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

Posted on 2013-01-03
4
565 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
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now