What I would like to happen is compare User to the UserID field in tbl_Employees. If they match and IsUMor IsSA is true to open the form frm_1WorkEntry. If User and UserID match and only IsDE is true then open form frm_1WorkEntry_DE. Everyone else would receive a message that they do not have the permission to use the form. Any help would be appreciated. This is what I came up with, but of course, it does not work:
Dim User As String, db As Database, RS2 As Recordset
Set db = CurrentDb()
Set RS2 = db.OpenRecordset("tbl_Employees", dbOpenDynaset)
User = txtUserID.Value
RS2.FindFirst ("[EmployeeID]" = User)
If RS2.NoMatch = False And RS2("IsUM").Value = True Or RS2("IsSA").Value = True Then
ElseIf RS2.NoMatch = False And RS2("IsUM").Value = False And RS2("IsSA").Value = False And RS2("IsDE").Value = True Then
MsgBox "You do not have permission to access this form", vbCritical, "Access Denied"
There is a possibility of txtUserID not existing in tbl_Employees. If there is an easier alternative, please let me know. Using Set RS2 = db.OpenRecordset("SELECT * FROM tbl_Employees WHERE EmployeeID = " & txtUserID), I receive a runtime error 3061 message: Too few parameters. Expected1.