By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

Error 2001: You Canceled the Previous Operation

P: 48
** Admin Edit - Split from Login Forms **
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub txtPassword_AfterUpdate()
  3. Dim pswd As String
  4. Dim confirm As String
  5.  
  6.   pswd = DLookup("[PasswordField]","TableName", "[UserNameField]='" & Me.txtUser & "')"
  7.  
  8.   If pswd = "password" Then
  9.  
  10. EnterPassword:
  11.  
  12.     pswd = InputBox "Please enter a new password", "Change Password"
  13.     confirm = InputBox "Please enter again for confirmation", "Confirm Password"
  14.     If pswd <> confirm Then
  15.      MsgBox "Passwords don't match. Please try again.", vbOKOnly
  16.      GoTo EnterPassword
  17.     Else
  18.      DoCmd.RunSQL "UPDATE tablename SET [passwordfield]= '" & Me.pswd & "' WHERE [UserNameField]='" & Me.txtUser & "';"
  19.     End If
  20.   Else
  21.      'Your normal password checking code here
  22.   End If    
  23.  
  24. End Sub
  25.  
  26.  
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:
Expand|Select|Wrap|Line Numbers
  1. pswd = DLookup("[Password]", "tblUsers", "[Username]=" & Me.txtUsername)
any idea how i can fix this?
Sep 24 '08 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,429
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.
Sep 24 '08 #2

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

Expand|Select|Wrap|Line Numbers
  1. pswd = DLookup("[Password]", "tblUsers", "[Username]='" & Me.txtUsername & "'")
Using the ' around the username should fix it. another option is

Expand|Select|Wrap|Line Numbers
  1. pswd = DLookup("[Password]", "tblUsers", "tblUsers.[Username]='" & Me.txtUsername & "'")
Not sure why the 2nd one will sometimes work and the first one won't.
Sep 24 '08 #3

P: 48
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
Sep 25 '08 #4

NeoPa
Expert Mod 15k+
P: 31,429
No big problem if it doesn't happen again :)

Is your problem solved now by the way?
Sep 25 '08 #5

NeoPa
Expert Mod 15k+
P: 31,429
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.
Sep 25 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.