Results 1 to 3 of 3
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Password Form Not Accepting My own Password

    Text0 is the password field and chkpswd is the command button to execute code. LIChk is the counter for
    number of password attempts. It says I am not entering the correct password when I am. 3 tries and it closes.


    Private Sub chkpswd_Click()

    Dim LIChk As Integer

    If IsNull(Forms!frmPassword!Text0.Value) Then 'No Blank passwords allowed
    MsgBox "You cannot enter a blank Password. Try again."
    Me!Text0.SetFocus

    End If


    If Me.LIChk.Value & "'" <> Me.LIChk.Value Then 'No More Than 3 Attempts Allowed
    Me.LIChk.Value = Me.LIChk.Value + 1
    If Me.LIChk.Value > 3 Then
    MsgBox "You may not make more than three Password entry attempts.", vbCritical + vbOKOnly, "Oops!"
    DoCmd.Quit
    Else
    MsgBox "The Password you entered is incorrect." & vbCrLf & _
    "Please enter your correct Password or contact your Application " & _
    "Administrator.", vbOKOnly, "Password for " & Me.Text0.Value & " Incorrect"
    Exit Sub
    End If


    If (Forms!frmPassword!Text0 = "**********") Then

    DoCmd.OpenForm "frmSetCloseState"
    DoCmd.Close acForm, Me.Name
    End If
    End If


    End Sub
    Last edited by burrina; 12-24-2012 at 09:43 PM. Reason: Upload Demo

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why declare LIChk variable? It isn't used.

    There is no table of users and passwords. There is nothing to compare a user's input with. Need at least one record with a password value to compare to. Are passwords supposed to be associated with username? I set up a table with one field and two records for passwords 'admin', 'other'.

    Also didn't provide frmSetCloseState so code will fail on line to open form.
    Code:
    If IsNull(Forms!frmPassword!Text0) Then               'No Blank passwords allowed
        MsgBox "You cannot enter a blank Password. Try again."
        Me!Text0.SetFocus
    Else
        'No More Than 3 Attempts Allowed
        If Me.LIChk > 2 Then
            MsgBox "You may not make more than three Password entry attempts.", vbCritical + vbOKOnly, "Oops!"
            DoCmd.Quit
        ElseIf IsNull(DLookup("Password", "Validation", "Password='" & Me.Text0 & "'")) Then
            Me.LIChk = Me.LIChk + 1
            MsgBox "The Password you entered is incorrect." & vbCrLf & _
               "Please enter your correct Password or contact your Application " & _
               "Administrator.", vbOKOnly, "Password " & Me.Text0.Value & " Incorrect"
        Else
            If Forms!frmPassword!Text0 = "admin" Then
                DoCmd.OpenForm "frmSetCloseState"
                DoCmd.Close acForm, Me.Name
            Else
                'do something for other users
            End If
        End If
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Thanks, I put together parts of that code, i.e. suggestions off the net. I do have a password table but I use that for Login purposes. Wanted to separate the two, maybe not a good idea. Sorry I left out the other form by mistake.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 07-24-2012, 06:10 PM
  2. Replies: 1
    Last Post: 06-22-2012, 08:05 AM
  3. Password Form
    By hitesh_asrani_j in forum Forms
    Replies: 1
    Last Post: 09-26-2011, 06:13 PM
  4. How to set a password to a form
    By heman85 in forum Security
    Replies: 0
    Last Post: 08-09-2008, 07:48 PM
  5. Change from old password to new password
    By richy in forum Security
    Replies: 0
    Last Post: 11-17-2005, 05:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums