thanks, sorted
my code for my login screen:
Code:
Option Compare Database
Option Explicit
Dim intMaxLogonAttempts As Integer
Dim intContactID As Integer
Dim intStoredLogonAttempts As Integer
Private Sub Form_Open(Cancel As Integer)
vLoginAttempts = 0
Me.Caption = "Login"
Me.txt_UserName.SetFocus
Me.lbl_Login_Error.Visible = False
Me.lbl_Click_Here.Visible = False
Me.lbl_Login_Count.Visible = False
End Sub
Private Sub cmd_Login_Click()
intMaxLogonAttempts = DLookup("[Value]", "tbl_DB_Properties", "[Propertyid] = 4")
If IsNull(DLookup("[Username]", "[tbl_Contacts]", "[UserName]='" & Me![txt_UserName] & "'")) Then
vDBUserName = ""
Else
vDBUserName = Me.txt_UserName
intContactID = (DLookup("[contactID]", "[tbl_Contacts]", "[UserName]='" & Me![txt_UserName] & "'"))
intStoredLogonAttempts = (DLookup("[logonAttempts]", "[tbl_Contacts]", "[UserName]='" & Me![txt_UserName] & "'"))
vLoginAttempts = intStoredLogonAttempts
End If
If IsNull(DLookup("[UserPassword]", "[tbl_Contacts]", "[UserName]='" & Me![txt_UserName] & "'")) Then
vDBUserPassword = ""
Else
vDBUserPassword = Me.txt_Password
End If
If Me.txt_Password.Value = DLookup("[UserPassword]", "[tbl_Contacts]", "[UserName]='" & Me![txt_UserName] & "'") Then
vLoginAttempts = 0
updateField "tbl_Contacts", "LogonAttempts", "UserName", vDBUserName, vLoginAttempts
MsgBox "it works. ", vbOKOnly, "all working!"
DoCmd.Close acForm, "frm_Login_Dialog", acSaveNo
' place form to open navigation form here
Else
Reset_Fields
vLoginAttempts = vLoginAttempts + 1
If vLoginAttempts = intMaxLogonAttempts Then
DoCmd.Close
MsgBox "all " & intMaxLogonAttempts & " attempts used. Database will now close", vbOKOnly, "Notice..."
Else
Me.lbl_Login_Count.Visible = True
Me.lbl_Login_Count.Caption = "You have used " & vLoginAttempts & " out of " & intMaxLogonAttempts & " login attempts. After all " & intMaxLogonAttempts & "have been used, you will be required to have your passwrod reset by an authorised user."
updateField "tbl_Contacts", "LogonAttempts", "UserName", vDBUserName, vLoginAttempts
End If
End If
End Sub
Private Sub cmd_Cancel_Click()
On Error GoTo Err_cmd_Cancel_Click
DoCmd.Close
Exit_cmd_Cancel_Click:
Exit Sub
Err_cmd_Cancel_Click:
MsgBox Err.Description
Resume Exit_cmd_Cancel_Click
End Sub
Private Sub lbl_Login_Error_Click()
MsgBox "Coming soon. Password management !! ", vbOKOnly, "Notice..!"
End Sub
Private Sub txt_Password_AfterUpdate()
cmd_Login_Click
End Sub
Private Function Reset_Fields()
Me.lbl_Login_Error.Visible = True
Me.lbl_Click_Here.Visible = True
Me.txt_UserName = ""
Me.txt_Password = ""
Me.txt_UserName.SetFocus
End Function