Results 1 to 5 of 5
  1. #1
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102

    Post how to add one to a DIM value after each failed password attempt?

    i have a login screen and want it to fail at 4th password attempt. how do i say to add 1 to the intLoginAttempts?

    I currentlry have it as:

    Dim intLoginAttempts as Integer
    intLoginAttempts = 0

    Else


    MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
    "Invalid Entry!"
    Me.txtPassword.SetFocus

    'If User Enters incorrect password 3 times database will shutdown
    intLoginAttempts = intLoginAttempts(, 1)
    If intLoginAttempts > 3 Then
    MsgBox "You do not have access to this database.Please contact admin.", _
    vbCritical, "Restricted Access!"
    Application.Quit
    End If

    n



    End If

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Options:

    1. set textbox on form with incremented value

    2. declare the variable in module header, not within the procedure, so it doesn't get reset to 0 every time the procedure runs and remove the line intLoginAttempts = 0

    The code you posted is incomplete - what event is it in?

    Syntax for incrementing the variable is:

    intLoginAttempts = intLoginAttempts + 1
    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
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Moderator,
    I am building my logon form and have pulled the following code from the internet: http://www.databasedev.co.uk/login.html
    it works correctly except for the last section of code counting the attempts and closing after 3 tries. I had modified it because it does not Dim the variable for intLogonAttempts and the placement of the counting sequence seems out of place. I have returned it to the original code as found in the article. but it still does not count...
    Also "I have added Encryption to the password for protection".

    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 Encrypt (Me.txtPassword.Value) = DLookup("strEmpPassword", "tblEmployees", _
    "[lngEmpID]=" & Me.cboEmployee.Value) Then

    lngMyEmpID = Me.cboEmployee.Value

    'Close logon form and open splash screen

    DoCmd.Close acForm, "frmLogon", acSaveNo
    DoCmd.OpenForm "Switchboard"

    Else MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
    "Invalid Entry!"
    Me.txtPassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database.Please contact admin.", _
    vbCritical, "Restricted Access!"
    Application.Quit
    End If

    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The example code does not declare the variable intLogonAttempts anywhere. It must be declared in the form module header. Aside from this, the code looks fine

    Did you declare the lngMyEmpID variable as instructed in the article?

    Did you download the example db?
    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.

  5. #5
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Moderator
    I had the lngMyEmpID declared incorrectly.
    Next, I will add some code so a user must set their password from this login screen if the password has not previously been established.
    Thank You

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

Similar Threads

  1. My First attempt at SQL
    By WhiskyLima in forum Misc
    Replies: 4
    Last Post: 04-08-2014, 09:54 AM
  2. Update Query functioning in second attempt
    By drunkenneo in forum Programming
    Replies: 2
    Last Post: 11-18-2013, 05:12 AM
  3. Building my Own Collection(s) - Attempt #2!
    By Rawb in forum Programming
    Replies: 2
    Last Post: 12-18-2012, 08:25 AM
  4. Replies: 7
    Last Post: 08-10-2012, 03:09 PM
  5. Failed attempt at concetenation
    By snowboarder234 in forum Queries
    Replies: 2
    Last Post: 07-12-2012, 09:02 AM

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