I found this easier:
Actually, global variables are easy to use. Like everything else, you've just got to know the "trick".
The first thing to do is to set up a module in which you define the public variables, such as:
Public strName as string
Public lngCount as long
(and so on)
Save the module under any name you want ("MyModule"?).
When you open your database, the modules are automatically executed and whatever public variables you defined in the module(s) will be available throughout your application.
It's also helpful to include in the module some functions that help you get to the values in the variables. For example:
Function ThisCount() as Long
ThisCount=lngCount
End Function
This may initially seem to be redundant, but it is the method that makes it easy to include the values of public variables as part of queries. And of course if you want to be able to do more involved calculations based on values in public variables, the functions also enable you to do that.
One area I've found public variables to be very useful for is to store a user's ID and work group based on a login form I created for applications. I can then use the values of the ID, work group, and other related items, such as selected true/false variables for access to different functions in the application. It also provides me with the data to post where I want to record the ID of the user who made changes.
From: Bob Sellman