473,401 Members | 2,068 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,401 software developers and data experts.

My Dlookup is 'canceled'

I am still struggling with trying to match a user supplied string with
strings in a field of a table, where spaces [probably eventually a
broader whitespace] are to be ignored.

Arno suggested that I use the Dlookup function, but I apparently can't
get its syntax right.

Access gives me "Run-time error '2001' You canceled the previous operation"

url: http://www.fontstuff.com/access/acctut15.htm,
a set of 'Access Tips' has this to say about this error:

"The next example must get the prize for the most confusing error
message that Access has to offer!
<snip>
....this message also appears when there is a different kind of error,
when you attempt to use an SQL statement from VBA in which the data
type of a WHERE clause's criteria does not match the data type of the
corresponding field. For example you might have a date field and
supply a text data type: WHERE tblStaff.BirthDate='Tuesday0#."
I am hopelessly confused in the jungle of single quotes, double
quotes, parantheses, square brackets...

Here are what I hope are the offending lines of code:

Dim A_ID As Integer
Dim DataVal As String

' ---DataVal = User choice w/ blanks removed---
DataVal = Replace(cboChooser.Text, Blank, Q2)
'^^^combobox text

' ---This Doesn't Work: it triggers the 'cancel'---
A_ID = DLookup("[AA_ID]", "A0toD", "Replace(" & _
[Name] & ", Blank, Q2) = '" _& DataVal & "'")
' ----But this does Work---
A_ID = DLookup("[AA_ID]", "A0toD", "[Name] = '" _
& DataVal & "'")

...so I hope that my error is somewhere in trying to insert the
Replace function into the Dlookup function.

What have I done?
--thelma

Nov 13 '05 #1
1 2347
Thelma, why don't you post back on the original thread ?

I told you that you could use DLookup, but I also told you this:
"The NotInList_event only occurs when LimitToList is set to True ..."
So you better DON'T use this event for what you need.

I will give you more info on the original thread, so others can also see what this is about.

Arno R
"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> schreef in bericht news:d7**********@uwm.edu...
I am still struggling with trying to match a user supplied string with
strings in a field of a table, where spaces [probably eventually a
broader whitespace] are to be ignored.

Arno suggested that I use the Dlookup function, but I apparently can't
get its syntax right.

Access gives me "Run-time error '2001' You canceled the previous operation"

url: http://www.fontstuff.com/access/acctut15.htm,
a set of 'Access Tips' has this to say about this error:

"The next example must get the prize for the most confusing error
message that Access has to offer!
<snip>
...this message also appears when there is a different kind of error,
when you attempt to use an SQL statement from VBA in which the data
type of a WHERE clause's criteria does not match the data type of the
corresponding field. For example you might have a date field and
supply a text data type: WHERE tblStaff.BirthDate='Tuesday0#."


I am hopelessly confused in the jungle of single quotes, double
quotes, parantheses, square brackets...

Here are what I hope are the offending lines of code:

Dim A_ID As Integer
Dim DataVal As String

' ---DataVal = User choice w/ blanks removed---
DataVal = Replace(cboChooser.Text, Blank, Q2)
'^^^combobox text

' ---This Doesn't Work: it triggers the 'cancel'---
A_ID = DLookup("[AA_ID]", "A0toD", "Replace(" & _
[Name] & ", Blank, Q2) = '" _& DataVal & "'")


' ----But this does Work---
A_ID = DLookup("[AA_ID]", "A0toD", "[Name] = '" _
& DataVal & "'")

...so I hope that my error is somewhere in trying to insert the
Replace function into the Dlookup function.

What have I done?
--thelma

Nov 13 '05 #2

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: 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: 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: Jit Prasad | last post by:
I have a working client-side Vb.Net (.net v1.0) app that talks to a Webspere webservice on a windows 2000 server. The client side app runs on a citrix server, also a Windows 2000 server. The app...
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...
2
by: nvs | last post by:
Hi All, My Access 2003 Application was created on MS XP and worked perfectly. After installing it on Vista I have noticed that DLookUp function does not work on Forms. It generates Error inside...
9
by: | last post by:
In my database I have a 'control table' in which basic info is stored about the application, for instance the application's path and the name of the company that is using it. In all of the...
30
by: DH22 | last post by:
Access 03 I'm currently having an issue using Dlookup when trying to reference a query (criteria syntax) Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.