January 17th, 2013, 06:38 AM
access welcome code
well, not sure if the title is correct ._.
here's my code, i use 2 forms Login and Menu
what i want is after logging via the Login Form. in the Menu it should write "Welcome, "username"" but i don't know what to search in google. so i need your help
Private Sub cmdLogin_Click()
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
'Check value of password to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("password", "tblUsers", _
"[ID]=" & Me.cboUsername.Value) Then
ID = Me.cboUsername.Value
'Close logon form and open loginmenu form
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
There isn't any code in Menu just macros to link to other forms
is there anyway to code it example:
Username :staff (staff only have Read-Only permission)
if i log in using "staff" from Login form, in Menu Form, after clicking on any of the forms "staff" won't be able to edit anything and it's only "staff" that is read-only when other username is logged in, they are able to edit it.
Me.AllowEdits = false
Me.allowaddition = false
Thanks in advance
January 17th, 2013, 08:41 AM
You could use a global variable to store the username. Do a google search for global variables, there's plenty of documentation out there. Then just refer to your global variable anytime you need to identity the user.
January 18th, 2013, 03:54 PM
Since you have process for user login, you have a table of user info - username, password, permission level?
A global variable will work but can be an aggravation when debugging code because when code execution is terminated, often the global variable loses its value.
I store user info on a form that always remains open, such as MainMenu, then it is always available for reference.