Microsoft Restrict-Access
September 11, 2007 10:56 AM   Subscribe

Microsoft Access: How do I save a 'global variable'?

Using Microsoft Access (2000/2003) how can I have a form (frmLogin) that prompts a user to enter their username, password, and a site. Then check the username and password against a table, and if valid, set two global variables with their username, and site.

How would I setup frmTwo that would then display these variables in form fields? How could I then progmatically remove or add buttons based on their username (or a permission level).
posted by SirStan to Computers & Internet (2 answers total)
 
If I'm reading you right, how about a make-table query that, if their username and password entered onto frmLogin are equal to values on the validation table, throws those two values into a new table (we'll call it tblLoginStorage, and note that it gets blown away and recreated each time the make-table query's run). Then have frmTwo populate its fields from the values on tblLoginStorage.

Adding or removing buttons based on username/permissions level is beyond my current muddled-by-a-cold ability to think out, I'm afraid.
posted by COBRA! at 11:55 AM on September 11, 2007


Best answer: You should be able to do the trick by simply declaring the variables outside the scope of any function/sub. For example, create a separate module and declare the variables with Public scope, e.g. with just the following three lines in the module's code:

Option Compare Database
Public login As String
Public password As String


Then you can assign values to (and read values from) the "login" and "password" variables from any form/module.
posted by Doofus Magoo at 12:18 PM on September 11, 2007


« Older How best to move a Projection HDTV without harming...   |   Flickr okay for professional photgraphers? Newer »
This thread is closed to new comments.