header

 

MyVbaClub.com 

VBA Access Application   

                                                                                        

 
<< Previous    1...   4  5  6  7  [8]    Next >>

Comparing password and making sure user is not doing brute force ativity.

The last step the program must do is to check whether the user name and password passed by users match the one stored in login table. If it's matched, then the main menu will be displayed. If it didn't match, then it will count how many login attempt has been done. If the user have tried 3 times, the program will shut down by itself.

Code:
 
If IsNull(DLookup("[UserName]", "Usys_tblUserAll", "[deletionIndicator] <> -1 and [UserName]='" & Me.txtUserID.Value & "' And [Password]='" & KeyCode(CStr(Me.txtPW.Value)) & "'")) Then
 MsgBox "Your User ID and Password do not match." & vbCrLf & vbCrLf & _
 "Please try again.", vbCritical + vbOKOnly, "Oops!"
 Me.LIChk.Value = Me.LIChk.Value + 1
 If Me.LIChk.Value > 2 Then
  MsgBox "Your User ID and Password still do not match. No Brute Force Hacking, please!", vbCritical + vbOKOnly, ""
  DoCmd.Quit
 End If
 Me.txtUserID.SetFocus
 Me.txtPW.Value = Null
 Exit Sub
End If

MsgBox "Voila! You've just logged In! ", vbInformation + vbOKOnly, ""

stDocName = "formMainMenu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmLogIn", acSaveNo

 (If you don’t know how to attach this code to ENTER button, please follow this step-by-step tutorial )

<< Previous    1...   4  5  6  7  [8]    Next >>