473,413 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Runtime Error 2001: You canceled the previous operation.

111 100+
I am creating simple login form with linked tables(atual tables are in SQL 2005) in access 2003.
Here is my code.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.  
  4. Private Sub cmdSignIn_Click()
  5. 'Check to see if data is entered into the UserName combo box
  6.  
  7.     If IsNull(Me.txtUsername) Or Me.txtUsername = "" Then
  8.       MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
  9.         Me.txtUsername.SetFocus
  10.         Exit Sub
  11.     End If
  12.  
  13.     'Check to see if data is entered into the password box
  14.  
  15.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  16.       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  17.         Me.txtPassword.SetFocus
  18.         Exit Sub
  19.     End If
  20.  
  21.     'Check value of password in tbl_ValUsers to see if this
  22.     'matches value chosen in combo box
  23.  
  24.     If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = " _
  25.                          & Me.txtUsername.Value) Then
  26.  
  27.         UserName = Me.txtUsername.Value
  28.  
  29.         'Close logon form and open splash screen
  30.  
  31.         DoCmd.Close acForm, "frmLogin", acSaveNo
  32.         DoCmd.OpenForm "Switchboard"
  33.  
  34.     Else
  35.       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
  36.             "Invalid Entry!"
  37.         Me.txtPassword.SetFocus
  38.     End If
  39.  
  40.     'If User Enters incorrect password 3 times database will shutdown
  41.  
  42.     intLogonAttempts = intLogonAttempts + 1
  43.     If intLogonAttempts > 3 Then
  44.       MsgBox "You do not have access to this database.Please contact admin.", _
  45.                vbCritical, "Restricted Access!"
  46.         Application.Quit
  47.     End If
  48.  
  49. End Sub
  50.  
  51. Private Sub txtUsername_AfterUpdate()
  52. Me.txtPassword.SetFocus
  53. End Sub
I am getting this run time error 2001 when I click on "Sign In" after entering Username and password. When I click on debug it takes me to the line in bold.
Any clue what is going on?
Nov 25 '09 #1

✓ answered by ChipR

Assuming the UserName field contains a string, you need to delimit it with quotes.
Expand|Select|Wrap|Line Numbers
  1. ..., "UserName = '" & txtUserName & "'") Then

3 4669
ChipR
1,287 Expert 1GB
Assuming the UserName field contains a string, you need to delimit it with quotes.
Expand|Select|Wrap|Line Numbers
  1. ..., "UserName = '" & txtUserName & "'") Then
Nov 25 '09 #2
missinglinq
3,532 Expert 2GB
One has to presume that txtUsername is Text, but your syntax
Expand|Select|Wrap|Line Numbers
  1. If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = " & Me.txtUsername.Value) Then 
is only correct for a Numeric Datatype. For Text it would be :
Expand|Select|Wrap|Line Numbers
  1. If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = '" & Me.txtUsername.Value  & "'") Then
Linq ;0)>
Nov 25 '09 #3
AccessBeetle
111 100+
Thanks that worked.!!
One more situation: how do we specify the criteria if we are matching the username that is on another form's textbox?
Something like this
If Me.txtSecurityCode.Value = DLookup("[SecurityCode]", "RadioLog_tblValUsers", "[UserName] =" & Forms!frmLogin!txtUsername) Then

Is this correct?
Nov 30 '09 #4

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

Similar topics

0
by: RWC | last post by:
Hi, I'm running into a problem with Access XP (SP2) that's driving me up the wall. It's Error 2001 "You canceled the previous operation". There is no voodoo going on really when I get this...
1
by: John A. | last post by:
This is a database in use on Terminal server, been reliable, no corruption problems. (so far) Designing a form, asked to save objects, Access put up a dialog box for the current form asking me...
20
by: Crayola465 | last post by:
I have been trying to figure this out for a couple weeks and after reading every post in the forum about the subject I have not found anything that works. I have two tables; 1) has company...
6
by: Widge | last post by:
I've been using code similar to this: Option Compare Database Private Sub Form_Open(Cancel As Integer) SetFilter
8
by: pukhton | last post by:
I am getting a yellowish block on Refresh statement under Medication_Name_AfterUpdate, and If i take it out it comes to the End sub... dont know what is goign on? This is what I have under Text52...
1
by: noneedforthis | last post by:
I'm a new user of Access/VB and ran in to this nasty wall. (Access 2003, VB6.3, Windows XP) Runtime Error 2001: You cancelled the previous operation. The highlighted line is the one where the...
7
by: David01 | last post by:
When I run some code behind a button i get a runtime error message. The strange thing is that the code run perfectly some months ago. Can some one help me ! Some additional information: The company...
7
jmoudy77
by: jmoudy77 | last post by:
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does...
1
by: Heather M | last post by:
I am receiving a Run-time 2001 You canceled the previous operation. I have a form which has unbound boxes where you select the date and set a role. The query runs for one role for every month. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.