Private Sub cmdCheck_Click()
'NOTE: declaring variables on the same line makes
'each one declared a variant apart from the first one!
Dim dbPWD As DAO.Database
Dim rsPWD As DAO.Recordset
Dim intResponse As Integer
Dim strSQL As String
intResponse = 0
strSQL = "Select * From tblpwd WHERE User_name = '" & _
txtUserName.Value & "' and Password = '" & txtPassword.Value & "'"
Set dbPWD = CurrentDb
Set rsPWD = dbPWD.OpenRecordset(strSQL, dbOpenDynaset)
If Not rsPWD.BOF And rsPWD.EOF Then
Form_Startup.Visible = True
Form_pwdAuth.Visible = False
Else
MsgBox ("Invalid Username or password, please try again")
intResponse = intResponse + 1
End If
If intResponse = 3 Then
MsgBox ("You have reached the maximum number of login attempts," & _
"please contact an administrator for further assistance.")
End If
End Sub