I have a logon script for my logon form. This is it (It works):
Within tblUsers I have:
Field Name | Data Type | Additional Info
username | text
password | text
rank | text | lookup
within frmUsers I have:
Name
txtUsername
txtPassword
txtConPas
cmboRank
When the user logs on I would like to add some code that will set a variable as the type of user that is logged on. So later I can customise the menus depending upon the rank of the user that is logged on. How do I do this?
Thanks
Code:
Private Sub cmdLogon_Click()
' Set up variables
Dim dbs As Database
Dim userstable As DAO.Recordset
Dim logonusername
Dim logonpassword
'get data from the logon form
logonusername = Trim(Forms![frmLogon]![txtusername])
logonpassword = Trim(Forms![frmLogon].[txtpassword])
' open database
Set db = CurrentDb()
'open the table
Set userstable = db.OpenRecordset("tblUsers", dbOpenDynaset)
'find the users name
userstable.FindFirst "username = '" & logonusername & "'"
If userstable.Fields("username") = logonusername Then
If userstable.Fields("password") = logonpassword Then
DoCmd.OpenForm ("frmMenu")
Else
MsgBox "Incorrect Password"
End If
Else
MsgBox "Incorrect Username"
End If
End Sub
Within tblUsers I have:
Field Name | Data Type | Additional Info
username | text
password | text
rank | text | lookup
within frmUsers I have:
Name
txtUsername
txtPassword
txtConPas
cmboRank
When the user logs on I would like to add some code that will set a variable as the type of user that is logged on. So later I can customise the menus depending upon the rank of the user that is logged on. How do I do this?
Thanks