Hello, please help me understand if the following would be seen as a null value, zero length, etc. I am using dlookup in an if, else statement, and my empty cells seem to be passing a not null value, because the code is running that is in the else clause...
I have a table with a single row where values exist for the purpose of calling them as variables on a form, and then set to null when not needed. (I do not wish to delete the record entirely)
I need to do a logic test to use this data if it is not null, else do nothing.
Even when the values being looked up by dlookup are set to null prior, this if statement is doimg the thing in the else clause...Code:If isnull(DLookup("field1", tablename) then 'Nothing Else Var = DLookup("field1", tablename) End if
Question is whether the dlookup is seeing a null value is still seen as "something" in this scenario because it found a row meeting its criteria (no criteria statement = return the only value in the table since there can only be one row).
See notes from microsoft:
That last bit seems to strongly suggest that if dlookup finds anything meeting its criteria, that it will not pass an isnull test...If criteria is omitted, the DLookup function evaluates expr against the entire domain.
And...
The DLookup function returns a single field value based on the information specified in criteria. Although criteria is an optional argument, if you don't supply a value for criteria, the DLookup function returns a random value in the domain.
And finally...
If no record satisfies criteria or if domain contains no records, the DLookup function returns a Null.
So does it return a zero length here, or what?
How do I test for that so that I only run my code when there is a data value present in the dlookup field?
Edit: I just read somewhere about vbNullString and Is Nothing
Would either of those do the trick for my use case?
Thanks!