[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Another Access 2007 Logon Question

Hi everyone,

I decided to ask a new question on the Access 2007 LOGON.  I need to have a msg box appear when a password is entered that is not in the database when a user enters one.

My coding:

Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmployee.SetFocus
End Sub

Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub

Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
            MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.cboEmployee.SetFocus
        Exit Sub
    End If

'Check to see if data is entered into the password box

    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
            MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
            Me.txtPassword.SetFocus
        Exit Sub
    End If

'Check value of password in tblEmployees to see if this matches value chosen in combo box

    If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

        lngMyEmpID = Me.cboEmployee.Value
        End If

'Close logon form and open splash screen
    If lngMyEmpID = "1" Or lngMyEmpID = "2" Or lngMyEmpID = "3" Then
       
  DoCmd.Close acForm, "frmLogon", acSaveNo
        DoCmd.OpenForm "Startup Screen"

     Else
        DoCmd.OpenForm "StartupScreen2"
 
End If


     
     
   
   
   
   
'If User Enters incorrect password 3 times database will shutdown
   
       
   
    If intLogonAttempts > 3 Then
        MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
        Application.Quit
    End If
   
End Sub


Where can I put some coding to chek for the incorrect entery of a password that does not exist in the sstem when entered by a user?
LOGON-FORM-001.jpg
0
jjc9809
Asked:
jjc9809
1 Solution
 
Rey Obrero (Capricorn1)Commented:


 'use this codes instead

'Check value of password in tblEmployees to see if this matches value chosen in combo box

 
     if nz(DLookup("strEmpPassword", "tblEmployees","[strEmpPassword]='" & Me.txtPassword & "' And  [lngEmpID]=" & Me.cboEmployee.Value),"") <> "" Then
     
        lngMyEmpID = Me.cboEmployee.Value
      else

      Msgbox "Message here"

      exit sub

     End If
0
 
jjc9809Author Commented:
Thanks

It works real good.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now