How do i declare a global variable that will be used throughout my application. I need this variable to store my user id, which will determine what the user can do on various screens. Thank you in advance
I have tried this but i receive an error saying
"Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules"
Is there anything that I have to set or do first of all. Thanks in advance
You can't set Global variables in an object based module (ie. the code for a form).
You will have to create a new module from the main module section and enter the code herman suggested there.
Is the "New" module just created in the module area? How does Access process this module first to know that the "global variable" defined is used in another Form?
Kumo,
Yes just create a new module and give it a meaningful name.
I'm not entirely sure of the ins and outs of how Access works with it's modules but I assume it updates a list, in memory, of the Public/Global Variables and Functions that are in each module, before it runs any form code.
Why not declare the variable in GLOBAL (Dim statement or PUBLIC) and set the values in the 'oncurrent' of your first or main form. I ususally just points to other forms, doing nothing else useful.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.