Quick DLookup question and another...

DNS809904

Db Contender
Local time
Today, 09:24
Joined
Oct 14, 2004
Messages
26
Quick DLookup question and "=" vs "<>"??

Hello,
I am rather new working with DLookup. I don't seem to be having any problems really with it yet, but I am only checking to see if a particular value is null or not. Will DLookup return an actual value is desired? If so would it be the "fieldname" entered matching whatever criteria I enter? I'm pretty sure I'm on the right track with that....

OK, the other question that has been haunting me for awhile... :rolleyes:
What, if any, is the difference between "=" and "<>" ???? :confused:

So far all I really use is =, but I have seen many people use <>, so I am really wondering what context it is meant to be used in.

Thanks in advance,
A naive prog. :)
 
Last edited:
<> usage...

Wait... is <> used for 'not equal to' ??? I just saw an if else statement that appeared that way.
Thanks in advance,
Dana
 
Both your assumptions are correct. DLookup will return the value of FieldName for the given criteria (first one it finds if more than one).

<> is "not equal to"
 
Quick DLookup question and "=" vs "<>"??

DLookup seems to have been covered so let’s have a look at the relational operations of "=" vs "<>".

Seems simple, two things are either equal or they are not equal.

Four, and there could be more, problems that can arise…

1. When comparing floating-point numbers.
When calculations are made on floating-point numbers the exact result may not be known.
Any slight difference would produce not equal.
Accepted method is to not look for equality in FP numbers.

2. When comparing strings.
String comparisons can be made in three ways Database, Text and Binary.

Compare Database…to tell the truth I don’t know what that means.
When looking for an answer a few years ago I tripped over this article by Michael Kaplan and haven’t used it since.

Compare Text…This compares strings without regard for case. A = a.
This method is usually what you want to do, ignore case, but it should prove slower than a binary comparison because it would need to check both cases if the first check fails.

Compare Binary… This compares strings with regard for case. A <> a.
Seldom used unless you are certain about the case of both arguments. Any single character that fails should immediately return False, no need to check the reverse case.

3. When comparing the numerical value of something to a VBA constant. A = True.
If (A = 1) then A is true but (A = True) is False. The VBA constant for True = -1.

4. When comparing anything to Null. If A = Null.
(A = Null) is False but IsNull(A) might be true.

Hope that helps.

Regards,
Chris.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom