John,
Thanks for your reply. I'm trying to lookup a category in a table. The
category is defined by the SKU being between the FirstEntry and the
NextEntry. This works most of the time, but for some reason when I use a SKU
of "5999" which is not in the table I get a message Error 94 Invalid Use of
Null. I tried to test for a null return from the dlookup but the value is
always "False" which seems to indicate success on the dlookup. Please let me
know if you have any other suggestions.
David
Dim FoundFlag As Boolean
Dim y As Boolean
MsgBox ProductUpdateSKU
y = IIf(IsNull(DLookup("Category", "tblCategories", "FirstEntry
<= '" & ProductUpdateSKU & "'" & " AND " & "NextEntry > '" & ProductUpdateSKU
& "'")), FoundFlag = True, FoundFlag = False)
MsgBox FoundFlag
Category = DLookup("Category", "tblCategories", "FirstEntry <=
'" & ProductUpdateSKU & "'" & " AND " & "NextEntry > '" & ProductUpdateSKU &
"'")
'MsgBox Category
John W. Vinson said:
On Mon, 23 Feb 2009 14:50:01 -0800, dhstein
I want to check if the DLOOKUP will be successful and take a different path
if not. Does Access have a command like that. In Excel it would be
something like =IF (ISERROR (VLOOKUP (aaaa,bbbb,cccc,dddd) ,DOGOOD,DOBAD)
In Access ?
IF ERRORRETURN = (DLOOKUP( AAAAAAA) Then ????????
do nothing
ELSE
MYCONTROL.VALUE = DLOOKUP(........)
END IF
The DLookUp function will return a NULL if there is no matching record to the
criterion:
IIF(IsNull(DLookUp("[fieldname]", "[tablename]", "<criteria>"), DoGood, DoBad)