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?