Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Public (Global) variables 1

Status
Not open for further replies.

BCarruth

Programmer
Feb 8, 2001
19
US
I am trying to create a modified version of Access's User Level Security. My scenario is as follows:

I have an opening password screen in which the user will select from a dropdown box their UserID, I have 1 hidden fields on the form that will contain their user level. What I need is to place that user level info into a global or public variable and use it elsewhere. I have the variable declared in a module, the variable is
Public varUserLvl as string
This is where I get confused, how do I populate the variable then use it again later? I've never used global variables before so pardon the ignorance.

Any help is greatly appreciated
Bob
 
Hi Bob,
I typically place Global Variables in a general module.

Global strUserLvl as string

notice I've kept with the "standards" and 'cause it's a string, it's prefixed with str...

In the after update event of your combobox in visual basic:
(event procedure) and "..." type in:

strUserLvl = Me![NameOfYourCombobox]

The global variable should now be set to the value in the bound column (their user level?!) of your combobox.

For later use, perhaps to have someone avoid opening a form:
In the form On Open event:
If struserlevel <> &quot;A&quot; Then
MsgBox &quot;Access denied.&quot;,vbCritical,&quot;Security check&quot;
Cancel = True
End if

:) Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top