Results 1 to 10 of 10
  1. #1
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10

    Run-time 2465 on Login Form with PWReset

    Good day,



    I have a login form [frmLogin] with combobox [cboUser] to select a User. Password is textbox [txtPassword]. The table containing the data is called [tblUsers]. [tblUsers] contains the following elements:
    UserID (AutoNmber)
    Fullname (Text)
    Password (Text)
    PWReset (Yes/No) set to True/False format
    AccessLevelID (Number)

    I also have a change password form [frmChangePassword].

    On the login form, there is a change password button that takes the user to the change password form, which is filtered for the current user, and allows them to change the password, which then updates the tblUsers with the password for the correct User. This button and change password function work fine.

    I have code in the AfterUpdate event of [txtPassword] on the login form that checks to see if the PWReset is set to True. If it is True, the change password form should open, filter for the current user, and allow them to change the password, just as they would when clicking the change password button on the login form. This, however, does not happen.

    This is the code for the AfterUpdate event on [txtPassword] on [frmLogin]:
    Code:
    Private Sub txtPassword_AfterUpdate()
          'Check that User is selected
     If IsNull(Me.cboUser) Then
        MsgBox "Please select a user", vbCritical
        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
                DoCmd.OpenForm "frmChangePassword", , , [UserID] = " & Me.cboUser"
            End If
            DoCmd.OpenForm "frmNMD_Switchboard"
            Me.Visible = False
        Else
            MsgBox "Password does not match, please re-enter your password", vboOkOnly + vbExclamation
            Me.txtPassword = Null
            Me.txtPassword.SetFocus
        End If
     End If
     End Sub
    When the PWReset is True on tblUsers, I receive the following error when logging in: "Run-time error '2465': NMD v.10 can't find the field '|1' referred to in your expression." Debug highlights this part:
    Code:
    DoCmd.OpenForm "frmChangePassword", , , [UserID] = " & Me.cboUser"
    The change password button has this:
    Code:
    Private Sub btn_ChangePassword_Click()
        DoCmd.OpenForm "frmChangePassword", , , [UserID] = " & Me.cboUser"
    End Sub
    ...and it works perfectly. What is wrong with the code in my AfterUpdate event?

    Your time and assistance are much appreciated.

  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
    Don't see how either can work. Quote marks are misplaced.

    DoCmd.OpenForm "frmChangePassword", , , "[UserID] = " & Me.cboUser

    Is UserID a number type field?

    Are you aware that holding down shift key when opening accdb file will bypass database option settings and not run this code?
    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
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10
    Thanks for the response, June.

    I'm aware of the Shift bypass. I think one or two of my users may be familiar with it as well, but it's not a big deal.

    When I change the quotes, I receive this error: "Run-time error '3075': Syntax error (missing operator) in query expression '[UserID] = Mr. Smith'." and the same line is highlighted in Debug.

    I don't understand how it works correctly on the button, but not on the PWReset check. When I change the quotes on the button, it doesn't filter for the current user and changes the password for the first user in the list. There's also no other code on the form besides an email button with an OnClick event. I've also C&R'd to see if that would clear it up.

    UserID is AutoNumber on tblUsers.

  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
    Well, 'Mr. Smith' is not a number. You are not getting UserID from the combobox.

    Again, another reason I don't understand how either code can work.
    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
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10
    Right, and I don't understand how the button works with that. I've changed UserID to Fullname in the AfterUpdate event and it allows me to go the change password form, but it then creates a new record in tblUsers and places the password there.

  6. #6
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10
    The combobox also has all fields from the tblUsers, the column widths are just set to "0" except for Fullname.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Which column is the combobox bound to?

    Why would focus go to a new record and automatically populate field?

    Would have to review code if you want to provide.
    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.

  8. #8
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10

    Sample

    Here's a snippet.

    Skeleton DB.zip

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    On frmChangePassword, remove "UserID =" from Filter property and set FilterOnLoad to No.

    Still don't have code right for opening form. Change to:

    DoCmd.OpenForm "frmChangePassword", , , "Fullname = '" & Me.cboUser & "'"

    But I would use UserID by setting BoundColumn to 1.

    DoCmd.OpenForm "frmChangePassword", , , "UserID = " & Me.cboUser
    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.

  10. #10
    Vodi's Avatar
    Vodi is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    10
    BOUNDCOLUMN!! That's what was giving me the problem in the first place. I never even looked at it. Thanks, June!

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

Similar Threads

  1. Replies: 13
    Last Post: 10-25-2012, 06:15 PM
  2. run time error 2465
    By karma in forum Access
    Replies: 3
    Last Post: 08-09-2012, 04:08 AM
  3. Run Time Error 2465
    By jo8701 in forum Programming
    Replies: 1
    Last Post: 02-08-2012, 12:01 PM
  4. Run Time Error 2465 In Report
    By desk4tbc in forum Programming
    Replies: 9
    Last Post: 09-06-2011, 08:00 PM
  5. Run-Time error '2465'
    By hawkins in forum Access
    Replies: 6
    Last Post: 08-19-2011, 04:07 PM

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