hi,
I've got this little challenge this week.
I do have a MS Access built in 2003 using security workgroup. There is a function called "displayRights" with the following attribute
Public Function displayRights (userName As String) As Boolean
displayRights = GetUserBoolValue(userName, "DisplayPrices")
End Function.
This is used to get the logged in username from that Workgroup and determine if he can access the price tags in other forms where VBA calls this variable.
What I would like to do is to create the same global variable (instead of changing the whole vba on each form.
I have create a login form, that calls a table where is myUser and myPassword. In the same table there is a field where I do specifiy (0 or -1) if the logged in user has right to access price tags.
The question is How can I store this login information so I can call it every time a form is opened and make sure the proper right is applied.
I don't really understand what you're asking. You can call the "displayRights" function from anywhere in the project, assuming it's stored in a Standard Module. You'd use it something like this:
If displayRights("YourUserNam
'/ do something here
Else
MsgBox "You don't have permission to open this form"
End If
If you're asking how to "store login information" then, again, I don't really understand. If you have a User table, then you could simply include a boolean field named IsLoggedIn, and set that value to True whenever someone logs in. This can be troublesome at times - for example, if the program crashes, you'd have to reset that field to False for all users in order to start back fresh.
If all you want to do is just store the UserName of the person who logged in, then the simplest way to do that is with a hidden form. Add a textbox to that form named "txUser", and set the value of that textbox when the user successfully logs in. You can then refer to that textbox as needed:
If Forms("YourHiddenForm").tx
'/ do something here
End If