Solved

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

Posted on 2013-01-03
4
567 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
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.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

825 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