Another Access 2007 Logon Question

Posted on 2011-10-17
Last Modified: 2012-05-12
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
End Sub

Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
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"
        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"
        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"

        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!"
    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?
Question by:jjc9809
    LVL 119

    Accepted Solution


     '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

          Msgbox "Message here"

          exit sub

         End If

    Author Closing Comment


    It works real good.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now