Skip to content

Instantly share code, notes, and snippets.

@aarontwf
Created March 19, 2013 02:00
Show Gist options
  • Save aarontwf/5193095 to your computer and use it in GitHub Desktop.
Save aarontwf/5193095 to your computer and use it in GitHub Desktop.
Simple Access login form code
' Blank Usernames
If IsNull(cboUsername) Or cboUsername = "" Then
MsgBox "Enter Username", vbOKOnly, "Required Data"
cboUsername.SetFocus
Exit Sub
End If
' Blank Passwords
If IsNull(txtPassword) Or txtPassword = "" Then
MsgBox "Enter Password", vbOKOnly, "Required Data"
txtPassword.SetFocus
Exit Sub
End If
' Password Check
If txtPassword.Value = DLookup("Password", "tblEmployees", "[ID]=" & cboUsername.Value) Then
MsgBox "Correct Password", vbOKOnly, "Login Successful"
Exit Sub
Else
MsgBox "Incorrect Password! Please try again.", vbExclamation, "Login Failed"
txtPassword.SetFocus
Exit Sub
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment