Try to create login form with security level, so that some users can only see reports and some can add/edit record as well.
getting Qualifier must be collection error
Private Sub Command4_Click()
Dim FRM As Integer
Dim Reports As Integer
FRM = DLookup("Forms", "User_Account", "UserName='" & Me.UserName & "'")
Reports = DLookup("Reports", "User_Account", "UserName='" & Me.UserName & "'")
' ~~~ Execution ~~~~~
If IsNull(Me.UserName) Then
MsgBox "Please enter the correct User Name!", vbCritical, "Denied"
Me.UserName.SetFocus
ElseIf IsNull(Me.Password) Then
MsgBox "Please enter the correct Password!", vbCritical, "Denied"
Me.TxtPassword.SetFocus
Else
If (IsNull(DLookup("UserName", "User_Account", "UserName='" & Me.UserName & "'"))) Or _
IsNull(DLookup("Password", "User_Account", "Password='" & Me.TxtPassword & "'")) Then
MsgBox "Please enter the correct Username and Password!", vbCritical, "Denied"
Me.UserName = ""
Me.TxtPassword = ""
Me.UserName.SetFocus
Else
If DLookup("Password", "User_Account", "UserName='" & Me.UserName & "'") <> Me.TxtPassword Then
MsgBox "Incorrect Username or Password!", vbCritical, "Denied"
Me.UserName = ""
Me.TxtPassword = ""
Me.UserName.SetFocus
Else
If FRM = -1 Or Reports = -1 Then
DoCmd.OpenForm "Navigation Form"
If FRM = -1 Then
DoCmd.OpenForm "Navigation Form"
FRM![Navigation Form]!Forms.Enabled = True
End If
If Reports = -1 Then
DoCmd.OpenForm "Navigation Form"
Reports![Navigation Form]!Reports.Enabled = True
End If
Else
MsgBox "You do not have permission" & vbCrLf & vbcrld & _
"Please contact Database Administrator", vbInformation, "Denied"
End If
End If
End If
End If
End Sub