473,770 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.BirthD ate='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(cboChoo ser.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 2385
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.BirthD ate='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(cboChoo ser.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
3323
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 ... : DoCmd.GoToRecord , , acNewRec = nBriefnum = sBriefstr = Date
2
14941
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 code I get the error "You canceled the previous operation" err msg. When clicking on Help I get a white screen. I haven't got the slightest idea what it means .... I pinned down that this error comes from the Dlookup function, because if I put...
1
1597
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 Variant varX = DLookup("", "tblQualityStaff", " = 1") MsgBox varX
4
5137
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 worked ok till I installed .Net v1.1 on the citrix, now I get an error when I get the app to use .NET v1.1. If the app uses .NET v1.0 (with .NET v1.1 stalled), then its ok, however I must use v1.1 for other reasons. Has somebody come across...
4
1496
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 do this but when you enter a text value such as A you get
2
1778
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 a text box. Interesting that this function works perfectly in Reports. If I run DLookUp inside a procedure (OnCurrent, for example) and try to see the result in MsgBox, it generates Error Message "You canceled the previous operation" from MS...
9
6634
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 application's reports I have a page footer with an unbound field that retrieves and shows the name of the company. This is done by Dlookup. My question is: is Dlookup the best way to do this, performance wise, or is there a more efficient way? Thanks in...
30
7279
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 (numeric), First_Name, and Last_Name (as text). My query is Query1 which is the following: SELECT L_Emps.Employee_ID, L_Emps.First_Name, L_Emps.Last_Name FROM L_Emps
15
3129
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 assign an Age Correction value to hearing test results - since some degree of hearing loss naturally occurs with aging - OSHA lets us calculate that in before determining if the employee has an actual "significant" hearing loss. Anyway...I have my...
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7451
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.