You just need to create a standard code module.
If you declare the variable as public, then all routines, and all modules
can use the variable.
Public strUserName as string
can be used in everywhere of an Access engine.
That is a bit different. Do note that variables that you declare can NOT be
used in sql, or forms "expressions". So, you can use the above variable
anywhere in code, but to use it in a control on a form, or in a report, or
in sql, you can't use the variable. However, you CAN use a declared function
virtually anywhere in ms-access.
So, you can declare a public function, and that CAN be used virtually
anywhere
Public Function MyUserName() as string
MyUserName = strUserName
end function
Now, you can place a text box on a form, and put as the data source for the
text box the function name
=MyUserName()
You could also use the above expression in a report, and the also in sql
expressions..
Do note that any un-handled error in ms-access will re-set both local, and
global vars. If you distribute a mde, then un-handle errors will NOT reset
those variables.