Results 1 to 4 of 4
  1. #1
    dascoli is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    16

    Password Change Issue

    I am having an issue with my login security that I built through VBA. Everything works pretty well, but I am having issues when I force the user to reset their password.

    I'm using this tutorial in order to build my security:
    http://www.accesssecurityblog.com/post/2011/04/02/Login-Security-using-Access-VBA.aspx


    The sample provided with that tutorial works flawlessly, but when I run my code (copied and pasted from their functioning model) I get a window that pops up requesting the UserID of the user wanting to change their password.

    Click image for larger version. 

Name:	paramValue.PNG 
Views:	11 
Size:	9.4 KB 
ID:	12517



    Here is the code that I am using for the login form.
    Code:
    Private Sub txtPassword_AfterUpdate()
    
    'Check that a user is selected
    If IsNull(Me.cboUser) Then
        'If no user is selected, display message box
        MsgBox "Please select a user before entering a password.", vbCritical
        'Move cursor into USER field
        Me.cboUser.SetFocus
    Else
        'Check for correct password
        If Me.txtPassword = Me.cboUser.Column(2) Then
            'Check if password needs to be reset
            If Me.cboUser.Column(3) = True Then
                MsgBox "Your UserID is " & Me.cboUser & ". Please enter your UserID into the next window to reset your password.", vbOKOnly
                DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
            End If
            DoCmd.OpenForm "frmMainMenu"
            Me.Visible = False
        Else
            'Upon incorrect password, display message box
            MsgBox "Incorrect password. Please try again.", vbCritical
            'Empty PASSWORD field for re-entry
            Me.txtPassword = Null
            'Move cursor to the PASSWORD field
            Me.txtPassword.SetFocus
        End If
    End If
    End Sub
    When I debug the error, it shows that this line is the problem:
    Code:
    DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
    I thought something may have been wrong, so I used some code to show what UserID is used at the moment. I thought that maybe the UserID wasn't getting picked up, but that isn't the case. This line of code shows the appropriate UserID.
    Code:
    MsgBox "Your UserID is " & Me.cboUser & ". Please enter your UserID into the next window to reset your password.", vbOKOnly
    When the correct UserID is put in entered, you can successfully change the password, but if the wrong ID is entered the password gets assigned to a new user.

    I'm not sure where I'm going wrong. As I said, the example provided by the tutorial works perfectly, but I cannot get this DB to function the same way.

    Thanks for any help guys!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The prompt would imply that UserID is not a field in frmPasswordChange's record source. Is it? If so, can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dascoli is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    16
    PBALDY IS THE MAN!!! Lol! Thank you so much for helping me solve these issues today! I really appreciate it!

    The record source did not include the UserID field. All I had to do was change the record source to the User table and it fixed it immediately! I can't thank you enough for all your help!

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Change Password form
    By turbo910 in forum Forms
    Replies: 16
    Last Post: 05-07-2015, 09:02 AM
  2. Replies: 1
    Last Post: 06-22-2012, 08:05 AM
  3. Password issue
    By normie in forum Access
    Replies: 1
    Last Post: 02-15-2012, 03:23 PM
  4. Password change issues
    By westeral in forum Access
    Replies: 0
    Last Post: 11-28-2009, 09:20 AM
  5. Change from old password to new password
    By richy in forum Security
    Replies: 0
    Last Post: 11-17-2005, 05:05 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