How can I disable the unnecessary Message Prompts when not needed?
The form works if the user enters the password correctly, but if a user enters the password incorrectly,
...then enters it correctly, the other Message Prompts (intLogonAttempts-2 & 3) comes up before moving on to where it’s supposed to go.
The code below is just for the Logon Command Button with the forms declaration, if you want to see the full form code please let me now, just started using vba so my coding is still horror like…
Thanks
Mark
The form works if the user enters the password correctly, but if a user enters the password incorrectly,
...then enters it correctly, the other Message Prompts (intLogonAttempts-2 & 3) comes up before moving on to where it’s supposed to go.
The code below is just for the Logon Command Button with the forms declaration, if you want to see the full form code please let me now, just started using vba so my coding is still horror like…
Code:
Option Compare Database
Private intLogonAttempts As Integer
Private Sub Logon_Click()
If IsNull(Me.UN) Or Me.UN = "" Then
MsgBox "You must enter a User Name.", vbExclamation, "Required Data"
Me.UN.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.PW) Or Me.PW = "" Then
MsgBox "You must enter a Password.", vbExclamation, "Required Data"
Me.PW.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.PW.Value = DLookup("EmpPsW", "sp0005", _
"[EmpID]=" & Me.UN.Value) Then
MyEmpID = Me.UN.Value
'Close logon form and update LoginParams
DoCmd.RunSQL "UPDATE sp0005 SET sp0005.EMPIO = Yes WHERE (((sp0005.EmpID)=[Forms]![F0000]![UN]));", -1
DoCmd.RunSQL "UPDATE sp0005 SET sp0005.EMPDI = =Now() WHERE (((sp0005.EmpID)=[Forms]![F0000]![UN]));", -1
DoCmd.OpenForm "F9999", acNormal, "", "", , acHidden
Forms!F9999.EUNI = Me.UN
Forms!F9999.EUNP = Me.EUNP
'Set Navigation Panes as per User Level
With CodeContextObject
If (.EUNP = 1) Then
DoCmd.NavigateTo "MASTER Navigation"
End If
If (.EUNP = 2) Then
DoCmd.NavigateTo "Navigation 1"
End If
If (.EUNP = 3) Then
DoCmd.NavigateTo "Navigation 2"
End If
If (.EUNP = 4) Then
DoCmd.NavigateTo "Navigation 3"
End If
End With
DoCmd.LockNavigationPane True
DoCmd.SelectObject acTable, , True
'Close Ative Form
DoCmd.Close acForm, "F0000", acSaveNo
Else
'If User Enters incorrect password 3 times database will shutdown
'Count the Login Attemps
intLogonAttempts = 0
intLogonAttempts = intLogonAttempts + 1
End If
If intLogonAttempts = 1 Then
MsgBox "Please re-enter your Password " & vbCr & vbCr & _
" 2 of 3 Login Attempts Remaining... ", vbExclamation, "Invalid Login"
End If
If intLogonAttempts = 2 Then
MsgBox "Please re-enter your Password " & vbCr & vbCr & _
" 1 of 3 Login Attempt Remaining... ", vbExclamation, "Invalid Login"
End If
If intLogonAttempts = 3 Then
MsgBox "0 Login Attempts Remaining! " & vbCr & vbCr & _
" Please contact your System's Administrator. " & vbCr & vbCr & _
" *** Shutting Down *** ", vbCritical, "Access Denied"
Application.Quit acQuitSaveNone
End If
End Sub
Mark