Multiuser Login VBA

goldres

New member
Local time
Today, 09:21
Joined
Oct 10, 2013
Messages
8
Using TempVars with Login form

I have been looking at the Northwind example database and would like to use the login dialog screen as the base login for my application.
I would like to add a password for the user to log on with. I have managed to get the process of the enter of the user name and then a password to work using VBA but where I am having a problem is then to set a temp variable with the users name that I can pass on to other forms.

In the example the login dialog uses a macro and settempvar which works prefectly. I have not been able to set this up in a macro (as in the example) so I have built the login in vba and all works except setting the temp variable to pass on. With the example you set the temp variable in the macro and then a default value on the property sheet of each screen as =[TempVars]![CurrentUserID] but when I try this with my VBA code it catches that last entry I made (the password) and uses that.

i am sure that it is very simple but I just cant get my mind around the solution.

Any suggestions please

Gary
 
Last edited:
The Syntax for setting up a Temporary Variable in VBA is given below:

TempVars.Add "VariableName", ValueToStore

Examples:

Code:
TempVars.Add "Age", 25

Code:
TempVars.Add "StudentName", "John"

To retrieve the value from a temporary variable:

Code:
x = TempVars![Age]
To clear a particular variable from memory:

Code:
TempVars.Remove "Age"

To Remove all Temporary Variables from Memory:

Code:
TempVars.RemoveAll
 
Hi

Thank you for your response.

I have tried using the TempVars.Add but it does not allow me to use a variable as the data. I am trying to pass the userid on my login screen (called CurrentUserID) as the tempVar so that I can use it in all the forms in my system. That is where I am having a problem as TempVar requires that you give the variable data as in 25 or "John" but I need to pass whatever is entered in CurrentUserID and keep that so that I can use it later

Any suggestions?
 

Users who are viewing this thread

Back
Top Bottom