I have a form that requires a username and password to advance further (I know this isn't the most recommended practice, but the people I work with wouldn't know how to get around if they tried.) Now the issue I am having is with adding a MsgBox that pops up when the password doesn't match rather than just do nothing at all if they don't. I am not sure where or how I need to go about adding this since I'm not very VBA savy. What happens when I do put in a msgbox is it just closes the form if it's wrong after you hit ok. If the password is right, it just sits there and doesn't do anything. Hopefully someone can point me in the right direction. All I want to do is set up an error box for when the password is incorrect similar to MsgBox "Password incorrect!", vbRetryCancel, "Password".
Here is my code:
Here is my code:
Code:
Private Sub cmdLogin_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer
strUser = Me.txtUser
If DCount("[TechPWD]", "Technicians Extended", "[Technician Name]='" & Me.txtUser & "'") > 0 Then
strPWD = DLookup("[TechPWD]", "Technicians Extended", "[Technician Name]='" & Me.txtUser & "'")
If strPWD = Me.txtPWD Then
intUSL = DLookup("[SecurityGroup]", "Technicians Extended", "[Technician Name]='" & Me.txtUser & "'")
Forms!frmUSL.txtUN = strUser
Forms!frmUSL.txtUSL = intUSL
Select Case intUSL
Case 1
DoCmd.OpenForm "Home", acNormal
Case 2
DoCmd.OpenForm "Home", acNormal, , , acFormReadOnly
Case 3
MsgBox "Not configured yet", vbExclamation, "Not configured"
Case 4
MsgBox "Not configured yet", vbExclamation, "Not configured"
End Select
DoCmd.Close acForm, "Login Dialog", acSaveNo
End If
End If
End Sub