stevefishwickuk
Registered User.
- Local time
- Today, 20:11
- Joined
- Apr 6, 2006
- Messages
- 14
I have the following code, which is used to validate users and forward them to a sample form.
I have a table with user IDs in and the code compares the users ID with IDs in table and either lets them go forward or kicks them out.
N.B. It also calls an audit process, but this is fully working.
What I would like to do is call a field in the same table as the ID's and then move the user to different forms depending on what level of access they have, but I don't know how to do it within this code.
Can anyone help?
Sub Test()
Dim dbs As Database
Dim userstable As DAO.Recordset
Dim strLogonusername As String
strLogonusername = Environ("USERNAME") ' get the user's RACF ID from Windows NT Registry.
' open database
Set dbs = CurrentDb()
'open the table
Set userstable = dbs.OpenRecordset("tblUsers", dbOpenDynaset)
'find the users name
userstable.FindFirst "fldRACF = '" & strLogonusername & "'" ' Get Data
If userstable.Fields("fldRACF") = strLogonusername Then ' Compare
DoCmd.OpenForm ("frmMenu") ' If exact match then forward user to frmMenu
DoCmd.Close acForm, "frmWarning", acSaveNo ' Close's the last form.
Call GetLoginDataSuccess
Else
MsgBox ("Sorry you have not been authorised to use this system, please contact your local administrator")
Call GetLoginDataFail
DoCmd.Quit ' Quit from the database if user is not listed in the table
End If
End Sub
I have a table with user IDs in and the code compares the users ID with IDs in table and either lets them go forward or kicks them out.
N.B. It also calls an audit process, but this is fully working.
What I would like to do is call a field in the same table as the ID's and then move the user to different forms depending on what level of access they have, but I don't know how to do it within this code.
Can anyone help?
Sub Test()
Dim dbs As Database
Dim userstable As DAO.Recordset
Dim strLogonusername As String
strLogonusername = Environ("USERNAME") ' get the user's RACF ID from Windows NT Registry.
' open database
Set dbs = CurrentDb()
'open the table
Set userstable = dbs.OpenRecordset("tblUsers", dbOpenDynaset)
'find the users name
userstable.FindFirst "fldRACF = '" & strLogonusername & "'" ' Get Data
If userstable.Fields("fldRACF") = strLogonusername Then ' Compare
DoCmd.OpenForm ("frmMenu") ' If exact match then forward user to frmMenu
DoCmd.Close acForm, "frmWarning", acSaveNo ' Close's the last form.
Call GetLoginDataSuccess
Else
MsgBox ("Sorry you have not been authorised to use this system, please contact your local administrator")
Call GetLoginDataFail
DoCmd.Quit ' Quit from the database if user is not listed in the table
End If
End Sub