Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
666 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 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