473,387 Members | 1,903 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,387 software developers and data experts.

in DLookup I get Error 2001 - says I cancelled previous operation. Huh?

I got this: "Error 2001 You cancelled the previous operation"

with this:

Private Sub courseCode_GotFocus()
Dim myDLookupResults As String
myDLookupResults = DLookup("courseID", "courses", "criteria= '" &
Forms!frmSelectCourses!courseDescription & "'")
lblMessages.Caption = "You are working on " & myDLookupResults
'insert myDLookupResults into a label called lblMessages
End Sub

The debugger correctly reads the record, so I don't think I have the wrong
code, or maybe I do. Any ideas?
Nov 13 '05 #1
2 6829
The only possible problem I see with what you posted is your use of "Criteria"
as a field name. It may be a reserved word. Try changing it to something else
and see what happens.

<<'insert myDLookupResults into a label called lblMessages>>
What is this? Is there more code you did not post?

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:VC*****************@nwrddc02.gnilink.net...
I got this: "Error 2001 You cancelled the previous operation"

with this:

Private Sub courseCode_GotFocus()
Dim myDLookupResults As String
myDLookupResults = DLookup("courseID", "courses", "criteria= '" &
Forms!frmSelectCourses!courseDescription & "'")
lblMessages.Caption = "You are working on " & myDLookupResults
'insert myDLookupResults into a label called lblMessages
End Sub

The debugger correctly reads the record, so I don't think I have the wrong
code, or maybe I do. Any ideas?

Nov 13 '05 #2
The error message means that Access was unable to assign the value from
DLookup(), because one of the arguments was wrong (i.e. the previous
operation - retrieving the value - was not successful).

Examples of what to look for:
1. Is there a field named "courseID" without a space?
2. Is there a table or query named "courses"?
3. Does the table have a field named "criteria?"
4. What is the data type of the criteria field? If Number, drop the extra
quotes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:VC*****************@nwrddc02.gnilink.net...
I got this: "Error 2001 You cancelled the previous operation"

with this:

Private Sub courseCode_GotFocus()
Dim myDLookupResults As String
myDLookupResults = DLookup("courseID", "courses", "criteria= '" &
Forms!frmSelectCourses!courseDescription & "'")
lblMessages.Caption = "You are working on " & myDLookupResults
'insert myDLookupResults into a label called lblMessages
End Sub

The debugger correctly reads the record, so I don't think I have the wrong
code, or maybe I do. Any ideas?

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, When I use the Dlookup function I get the errormsg "Runtime error 2001 - You canceled the previous operation" ... Can anybody tell me what I do wrong here ? Here is the snippet ... : ...
2
by: sherah | last post by:
I am trying to create a procedure that has values are entered into a table that based on the value entered will programatically decide weather or not the Yes/No should be checked. I am trying to...
2
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the...
1
by: Thelma Lubkin | last post by:
I am still struggling with trying to match a user supplied string with strings in a field of a table, where spaces are to be ignored. Arno suggested that I use the Dlookup function, but I...
1
by: Tempy | last post by:
Good day, I have put the below into Module1 and get an error message "Run-Time error '2001'" "You canceled the previous operation". Can anybody tell me what is wrong ? Sub test() Dim varX As...
4
by: sparks | last post by:
If Not IsNull(DLookup(, "tblDemographic", " = """ & Me.Text9 & """")) Then Cancel = True MsgBox "Duplicate Value is Not Allowed" ActiveControl.Undo DoCmd.RunCommand acCmdUndo End If I try to...
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: Neekos | last post by:
Some of this may look familar to some of you, as part of it was posted previously. As i got farther along, i realized i was missing part of it and had to go back and redesign. The code is not fully...
2
by: Constantine AI | last post by:
I am trying to use the following code: Dim strFilter As String strFilter = "= " & !!! Assessment_Word_Limit = DLookup("", "tblAssessment", strFilter) Could anyone please tell me why this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.