Global declarations

J

JMorrell

I have a form that has several [Event Procedure]s. At the form's On Open
event, I run a function to capture data which is used throughout the form. I
would like to be able to use this data in the different Event Procedures. Do
I have to declare the variables, run the function, and pass the info back at
each event? Can’t I do a global declaration so that I won’t have to do that?
What are the pros and cons for doing this?

Tia,
JMorrell
 
A

Arvin Meyer

In a standard module declare your variables. The keyword "Global" will work,
but has been replaced by "Public"

So your variables will look like:

Public UserName As String
or
Public ctlEmpID As Control

You can also declare functions (such as APIs)
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
J

JMorrell

Thanks for the reply.

I understand now about public declarations, but can a dlookup() be done once
and used in other parts of the form?

tia,
JMorrell


Arvin Meyer said:
In a standard module declare your variables. The keyword "Global" will work,
but has been replaced by "Public"

So your variables will look like:

Public UserName As String
or
Public ctlEmpID As Control

You can also declare functions (such as APIs)
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access

JMorrell said:
I have a form that has several [Event Procedure]s. At the form's On Open
event, I run a function to capture data which is used throughout the form. I
would like to be able to use this data in the different Event Procedures. Do
I have to declare the variables, run the function, and pass the info back at
each event? Can't I do a global declaration so that I won't have to do that?
What are the pros and cons for doing this?

Tia,
JMorrell
 
Top