I have tried using DLookUp in this manner...
If DLookUp("[ClientID]","tblClients","[HPhone]='2021234567'") Then
MsgBox "Found it!"
End If
I am wondering if that is a misuse of the DLookUp command?
Type mismatch errors keep popping up. Take a look at this
I typed in the immediate window...
?DLookup("[VehicleMake]", "tblVehicleNames",
"[VehicleMake]=GetCurrentVehicleMake()")
Acura
Acura was returned, as expected.
But when I run the following code in a form module, I
get a type mismatch error running the If DLookUp line...
CurrentVehicleMake = Me!VehicleMake
If DLookup("[VehicleMake]", "tblVehicleNames",
"[VehicleMake]=GetCurrentVehicleMake()") Then
Exit Sub
Else
MySQL = "INSERT INTO tblVehicleNames (VehicleMake) SELECT
GetCurrentVehicleMake() AS MyNewMake;"
DoCmd.SetWarnings False
DoCmd.RunSQL MySQL
DoCmd.SetWarnings True
End If
Is it a mistaken belief that if something other than Null is returned
by by the DLookUp function in an If - DLookUp - Then clause
that the If conditional is presumed True and the contents inside the
If - End If wrapper are processed? Have I somehow bastardized the
whole concept, or did this use to work? 4 1839
Is it because the DLookUp is returning a string???
A string cannot be evaluated as True or False.
That may be the problem. Here is an example of
a scenario that works - without a hitch...
? dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2")
116
if dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2") then
msgbox "Hello"
Both of the above lines in the immediate window work as expected.
Of course, 116 evaluates to True a heck of a lot more reliably than
does "Acura". If you agree this is the root of my problem, pls let me
know you concur. Am tired of struggling with this.
"MLH" <CR**@NorthState.net> wrote in message
news:09********************************@4ax.com... Is it because the DLookUp is returning a string??? A string cannot be evaluated as True or False. That may be the problem. Here is an example of a scenario that works - without a hitch...
? dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2") 116
if dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2") then msgbox "Hello"
Both of the above lines in the immediate window work as expected. Of course, 116 evaluates to True a heck of a lot more reliably than does "Acura". If you agree this is the root of my problem, pls let me know you concur. Am tired of struggling with this.
Why not just test for Null?
If Not IsNull(dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2")) Then
MsgBox "Hello"
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Believe me, I will from now on. Its much clearer.
Thx for the hint.
xxxxxxxxxxxxxxxxxxxxxxxxxxx Why not just test for Null?
If Not IsNull(dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2")) Then MsgBox "Hello"
Rick Brandt wrote: "MLH" <CR**@NorthState.net> wrote in message news:09********************************@4ax.com...
Is it because the DLookUp is returning a string??? A string cannot be evaluated as True or False. That may be the problem. Here is an example of a scenario that works - without a hitch...
? dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2") 116
if dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2") then msgbox "Hello"
Both of the above lines in the immediate window work as expected. Of course, 116 evaluates to True a heck of a lot more reliably than does "Acura". If you agree this is the root of my problem, pls let me know you concur. Am tired of struggling with this.
Why not just test for Null?
If Not IsNull(dlookup("[vehiclejobid]","tblvehiclejobs","[ownerid]=2")) Then MsgBox "Hello"
Or use DCount() if checking for existence.
--
[OO=00=OO] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KLAU |
last post by:
I have a field that retrieves information from an expression in a
query. I have used a DLookup function to get the calculated field
from the query. However, the relationship is 1-to-many so one...
|
by: JLM |
last post by:
What am I missing here?
I have a form where I enter a "Class Code". This value corresponds to what
sits in table "class code descriptions" along with the "title" of each
"class code." Key...
|
by: ctyrrell |
last post by:
I have read with interest the many discussions of the 3048 Error:
Cannot open any more databases. I understand how the number of open
Table ID's causes the problem. My question has to do with the...
|
by: Christine Henderson |
last post by:
I have a problem using the above function in the following simplified
circumstance:
In the lookup table called "Klms Travelled" I have 3 fields, eg:
Receiver Name Receiver Suburb ...
|
by: MLH |
last post by:
DLookup("", "tblPreliminaryVINs",
"=Forms!frmVINODO!SerialNum")
is giving me a Type Mismatch error. That's confusing to me
and I don't know how to circumvent it. The field in...
| |
by: Don |
last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with
Access. I've been creating databases for several years for work with the
help of many of you and trial and error.
I have...
|
by: mindlike |
last post by:
I have a form "DataEntry" with various fields "Ticker", "TickerName", etc. I
want to autofill the "TickerName" field when I insert the Ticker in the
"Ticker" field. So when I put IBM into the...
|
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...
|
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...
|
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,...
|
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: 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,...
|
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...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |