global variable changes???

kato68

Registered User.
Local time
Today, 12:03
Joined
May 12, 2003
Messages
45
I have numerous reports that are used for different clients. At the top of each report is says the client's name. Everytime I run the reports for a new client I need to go into each report and change the name which takes about 2 hours. Is there a way to make some type of global change somewhere and only have to change it once??? I cannot use subreports because the reports are pretty simple and my boss wants to keep them that way. And I cannot use forms because I dont want to users to have to input anything.

Thanks,
Kate
 
If you declare a Public variable in a Module then the contents of this variable will be available to all of your reports.

Code:
Public strClientName as string
Declares a string variable called strClientName
In each Reports Report_Open event you can assign the value of strClientName to a textbox on your report.

Is this of any help?

Regards,
Patrick
 
Why not just use the Where condition of the open Report method?
 
Ok, Im trying to do what you said Patrick but Im getting errors.

I put this in a module:
public strTownship as string
strTownship = "test"

then in an on open function i have:
txtTownshipName = strTownship

I get an error that says "procedure declaration does not match description of event or procedure having the same name"

-------------------------------------

What do you mean use the Where condition?
 
I get an error that says "procedure declaration does not match description of event or procedure having the same name"

Have you got the code in the Report_Open event?
I.e.
Code:
Private Sub Report_Open(Cancel As Integer)

   txtTownshipName = strTownship
 
End Sub
 
Ok, I had something misspelled, but now it gets an error in the modules highlighting "test" where I have
strTownship = "test"
and it says "compile error, invalid outside procedure"
 
What do I put in the control source of the textbox?
 
DoCmd.OpenReport "YourReport", acNormal, "", "[fldID]=[Forms]![YouForm]![YourTextBox]"
This is just one example of using the Where clause, Help has many examples and many more have been posted here
 
1. You don't need anything in the ControlSource of the TextBox - it is Unbound
2. The reason you are getting the second error is because you are performing an assignment statement in the general declarations section of the Module.

try this out:
In the Module, leave your Public strTownship as string declaration alone & remove your assignment statement.
Add this:
Code:
Public sub AssignMe()
 strTownship = "test" 
End Sub

In your Report_Open event add this:
Code:
call AssignMe
 
Ok, now I get an error at the line:
txtTownship = strTownship

its says 'you cannot assign a value to this object'

-------------------------------
Leave it to me to make something simple rediculously complicated...
 
There is always a simpler way..
If you have a look at the quick n' dirty attached example you'll see.
If you set the ControlSource of the Report textbox to a textbox on the form from which you are opening it then it works.

Hopefully this'll do the job for you.
 

Attachments

Im not suppose to use forms. There is around 50 reports, and my boss doesnt want have a form attached to all of these. Which is quite annoying, cause a form would make is to much easier.

I tried doing txtTownshipName.value = "test"
which also didnt work, but I dont know if thats somewhat the problem. (that i just have txtTownshipName =)

Thank you so much for your help, I really appreciate it.
 
The problem seems to be with assigning values to controls on Reports in general.

I'll have a look into it for you.
If I don't post back this evening I'll post tomorrow morning.

Regards,
Patrick.
 
Just before I leave..
Here is another quick n' dirty example which uses a Dlookup to get the Client name from the table.
Each time you want to change the Client Name just change the
Client name in the table.

If you Open the Report you'll see what I mean.

Is this a solution?
 

Attachments

That works perfectly!

Thank you sooo much!

Of course its sooo simple.

:D
 

Users who are viewing this thread

Back
Top Bottom