Do to select a field with "nothing"

Hek

Registered User.
Local time
Today, 15:45
Joined
Oct 30, 2018
Messages
73
Hi all,

I currently don't know how select a field which has nothing in it using an if.
The pseudo code looks like this:
If [Employee] = nothing then
[employee] =23

I don't know what to put in the code to use nothing as a criteria
I've tried searching this up but only ended up confusing myself more.

Any help would be greatly appreciated

Regards
Hek
 
If IsNull(Employee) or Employee = "" then
Employee = 23
end if


Not sure what you mean by Emloyee = 23 means.
 
Thank you that worked perfectly
 
BTW
Although IsNull() will also work in a query, the SQL condition should be used instead.
Code:
WHERE [somefield] Is Null

Nothing means an object that doesn't exist.
That test is:
Code:
If SomeObjectVariable Is Nothing Then
 
Hek, "Nothing" is a keyword that only works reasonably well with object variables and it specifically means "object not instantiated" when used.

Ordinary variables (other than VBA VARIANT) and any field usable by SQL will not work with object references, so NOTHING doesn't apply to them. Ordinary variables can be empty, tested via ISEMPTY(), or null, tested via ISNULL().
 

Users who are viewing this thread

Back
Top Bottom