Error 2001: You Canceled the Previous Operation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zandiT
    New Member
    • Sep 2008
    • 48

    #1

    Error 2001: You Canceled the Previous Operation

    ** Admin Edit - Split from Login Forms **
    Originally posted by msquared
    Assuming your password is set to a default like "Password".

    You don't say if the username is entered freely or chosen from a dropdown list. I'm assuming it's entered freely (txtUser for this example).

    In the textbox where the password is entered (txtPassword for this example) create an After Update event using the following code.

    Code:
     
    Private Sub txtPassword_AfterUpdate()
    Dim pswd As String
    Dim confirm As String
     
      pswd = DLookup("[PasswordField]","TableName", "[UserNameField]='" & Me.txtUser & "')"
     
      If pswd = "password" Then
     
    EnterPassword:
     
    	pswd = InputBox "Please enter a new password", "Change Password"
    	confirm = InputBox "Please enter again for confirmation", "Confirm Password"
    	If pswd <> confirm Then
    	 MsgBox "Passwords don't match. Please try again.", vbOKOnly
    	 GoTo EnterPassword
    	Else
    	 DoCmd.RunSQL "UPDATE tablename SET [passwordfield]= '" & Me.pswd & "' WHERE [UserNameField]='" & Me.txtUser & "';"
    	End If
      Else
    	 'Your normal password checking code here
      End If	
     
    End Sub
    hi i need to do the exact same thing that you've done in your code for changing the password. its the same scenario like you've stated. txtpassword and the user types their own user name in txtusername. i have a table with the list of user names and their passwords and the log in executes properly.Now i need to give them the option of changing their passwords.
    i ran the code and i keep getting an runtime error 2001: You cancelled the previous operation, in the following line:
    Code:
    pswd = DLookup("[Password]", "tblUsers", "[Username]=" & Me.txtUsername)
    any idea how i can fix this?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    You have asked your question in another member's thread. This is called thread hijacking and is not allowed on this site. There are various reasons for this, the principal of which is that it typically diverts the flow of the thread away from their needs and into yours. Another is that it will tend to mean that your new question is not seen as such, and may get overlooked by many of our experts (You appreciate that they're not looking for answered questions).
    Please post your questions in their own threads in future (See How to Ask a Question).

    Administrator.

    Comment

    • Arweena
      New Member
      • Dec 2007
      • 5

      #3
      I'm assuming your Password field is a text field, if that's the case try changing the code to be

      Code:
      pswd = DLookup("[Password]", "tblUsers", "[Username]='" & Me.txtUsername & "'")
      Using the ' around the username should fix it. another option is

      Code:
      pswd = DLookup("[Password]", "tblUsers", "tblUsers.[Username]='" & Me.txtUsername & "'")
      Not sure why the 2nd one will sometimes work and the first one won't.

      Comment

      • zandiT
        New Member
        • Sep 2008
        • 48

        #4
        Originally posted by NeoPa
        You have asked your question in another member's thread. This is called thread hijacking and is not allowed on this site. There are various reasons for this, the principal of which is that it typically diverts the flow of the thread away from their needs and into yours. Another is that it will tend to mean that your new question is not seen as such, and may get overlooked by many of our experts (You appreciate that they're not looking for answered questions).
        Please post your questions in their own threads in future (See How to Ask a Question).

        Administrator.
        sorry about that, it wont' happen again in future

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          No big problem if it doesn't happen again :)

          Is your problem solved now by the way?

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            Actually, I just had this problem myself looking at somebody else's problem yesterday.

            I found that this occurs from within a Domain Aggregate (DLookup(), DMin(), DMax(), etc) function call if the call is not set up correctly.

            Try tracing through and seeing if you can find what is not right in your DLookup() line.

            Comment

            Working...