Solved

How do I resolve the error "Run time error '2001': You canceled the previous operation" in an Access 2003 application?

Posted on 2013-06-27
1
610 Views
Last Modified: 2013-06-27
I am developing an Access 2003 application using VBA code.
For my log on screen, I use a combobox control for the userID,
a text box to enter a password and a submit command button to validate the
values.

the tblUserSecurity1 table has the following fields:
primary key    recordnum             AutoNumber
                              userID                     Text
                              securityLevel        Text
                              password                Text  

The combox displays the userID but is based on the following Row source:
SELECT tblUserSecurity1.recordnum, tblUserSecurity1.userID FROM tblUserSecurity1 ORDER BY [userID];  

My log on FORM code is as follows:
After the Login ID and password are entered, the following error occurs:

Run time error '2001':
You canceled the previous operation.

The system stops at the line:
strUSERRIGHTS = DLookup("secLevel", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value)
---------------------------------------------------------------------------------------------

 If IsNull(Me.Combo25) Or Me.Combo25 = "" Then
       MsgBox "You must enter a valid login ID.", vbOKOnly, "Required Data"
       Me.Combo25.SetFocus
       Exit Sub
    End If
   
    'Check to see if data is entered into the password box
   
    If IsNull(Me.TxtPwd) Or Me.TxtPwd = "" Then
       MsgBox "You must enter a Password", vbOKOnly, "Required Data"
       Me.TxtPwd.SetFocus
       Exit Sub
    End If
   
    If Me.TxtPwd.Value = DLookup("PASSWORD", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value) Then
       strUSER = DLookup("UserID", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value)
       strUSERRIGHTS = DLookup("secLevel", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value)
       'USERRIGHTSM = strUSERRIGHTS
       'DoCmd.Close acForm, "frmLogon", acSaveNo
       'DoCmd.OpenForm "frmCustomRpt"
       
    Else
       MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
       Me.TxtPwd.SetFocus
    End If
   
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
       MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
       Application.Quit
    End If
0
Comment
Question by:zimmer9
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39283497
you mentioned "securityLevel" is the name of the field,

you are using "secLevel" in this line

strUSERRIGHTS = DLookup("secLevel", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value)

try

strUSERRIGHTS = DLookup("securityLevel", "tblUserSecurity1", "[recordnum]=" & Me.Combo25.Value)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question