It's the same principle as that for the form module you mention, except you place the definition in any global code module - one that is available to you from the Modules tab in Access. If there isn't one then you need to add a new one.
If you were to place a variable declaration such as
In a named code public code module you can access its value from any other code module regardless of its scope. I would caution that the use of global variables is frowned upon, as their location is hidden away from their use, and they are accessed without being passed through argument lists to subroutines and functions (by what is known as a 'side effect' in structured programming terms - not a good thing).
Nowadays I tend to use static variables within subs and functions where I would previously have used a global variable. Static variables are locally-defined variables internal to a subroutine or function which retain their values between calls, doing away with the need for side-effect based coding.
-Stewart