Solved

global variable for access reports

Posted on 2013-11-25
7
441 Views
Last Modified: 2013-11-25
I've inherited an access database.  it has lots of reports.  I have to make changes to some of the reports.  That changes I have to make are things like changing the names and titles of employees, like "Joe Smith, Director of Residential Service".    This is currently hardcoded in the reports.  Is there an easy way to feed this data from an access table or a global-type variable, so that the next time I only need to change the data in one place?
0
Comment
Question by:HLRosenberger
7 Comments
 
LVL 4

Assisted Solution

by:AccessGuy1763
AccessGuy1763 earned 125 total points
ID: 39674741
Yep!  You just need to declare them in a global Module.

If you have one already, you can put the global variables there or you can open the VB Editor and do Insert > Module.

Although it's not required, global variable declarations typically are found at the top of the Module, above any global functions or subroutines in the same Module.

So your declaration for the above variable might look like this:
Dim strDirOfResServ as string

Then you can set it in the same global module or anywhere else, since it's global:
strDirOfResServ = "Joe Smith, Director of Residential Service"

Now the part that might be a little tricky is that I think you'll need to use code to set the captions:
me.lblDirOfResServ.Caption = strDirOfResServ
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 125 total points
ID: 39674743
you need to create a table with the names and title of the people.
tblPeople
ID
Name
Title

use at least three fields as mentioned above
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 250 total points
ID: 39674745
If this is a  titles/heading,  for your reports you can include it in a table and use the following as a controlsource property:

 = DLookup("HeaderInfo", "YourTable")


However, if you have an employees table and their positions/title are included in the employeeInfo table you might be able to work that information into the recordsource query of your report.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 39674947
For all 3 of these ideas, how do I then reference the data/field/variable inside the reports, in a simple label object?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 39675026
Use a textbox instead of a label.  The DLookup syntax goes in the Control Source property, including the = sign like this:



 = DLookup("HeaderInfo", "YourTable")
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39675031
Any of these ideas would use textboxes, I think.  The textbox control source gives you more flexibility than the caption property of a label.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 39675041
Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

839 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