Using Global Variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello to all,

Is there a way to use a global variable in my reports and forms?

I have 3 forms and 3 reports that need to have an agents name appear in the
header section when opened.

What I want to do is create a global variable that holds a name, then use
that variable inside the forms and reports. That way, when I update the
variable all the modules will update too.

Is there a way to set up a variable in all modules to make updating easier?

-Sky
 
Create a small public function that returns the variable. You can then set
the control source of a control/text box to:
=GetAgentName()
 
Duane,

In my form named "Main" I created the function like this:

Public Function GetAgentName() As String
GetAgentName = "John Doe"
End Function

So John Doe appears at the top of the "Main" form so this works.

Now, in the "Main" form I have a control that opens a report which also has
a textbox with =GetAgentName() as control source. When the report opens I get
a popup window which says:

Enter Parameter Value

If I enter a value or leave it blank the following appears in report window:

#Name?

What went wrong here? Did I miss a step some place?

-Sky
 
Duane,

Thanks for your help on this. I didn't know about standard, class and other
types of modules and differences between them. Now that I know, things are so
much easier since I don't have to re-invent the wheel.

Thank you very much!

-Sky
 
Back
Top