Not IsNull

kitty77

Registered User.
Local time
Today, 09:02
Joined
May 27, 2019
Messages
715
I'm working with the following...
If Not IsNull([test]) Then MsgBox "testing 123"

It does not seem to be working. Some records that are blank or empty or null show the MsgBox.

How can I make it check for blank, empty and null?

It seems like some value must be there even though you can't see anything...

Thanks.
 
Have you tried adding an or eg :TextField IS NULL OR TextField=""

Just an idea

Ypma
 
I'm working with the following...
If Not IsNull([test]) Then MsgBox "testing 123"

It does not seem to be working. Some records that are blank or empty or null show the MsgBox.

How can I make it check for blank, empty and null?

It seems like some value must be there even though you can't see anything...

Thanks.

Blank ot empty is not Null?
You could have a zero length string ZLS ""
 
If Nz(TestField,””)=“”) Then MsgBox “123”


Sent from my iPhone using Tapatalk
 
I can't take credit for this as found it on the web so many years ago I forgot when but use it all the time.


Code:
Function IsNothing(varToTest As Variant) As Boolean
'Function found on web
On Error GoTo HandleErr

    IsNothing = True

    Select Case VarType(varToTest)
        Case vbEmpty
            Exit Function
        Case vbNull
            Exit Function
        Case vbBoolean
            If varToTest Then IsNothing = False
        Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency
            If varToTest <> 0 Then IsNothing = False
        Case vbDate
            IsNothing = False
        Case vbString
            If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing = False
    End Select
    
HandleExit:
    Exit Function
    
HandleErr:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
            Resume HandleExit
        Resume
    End Select
 
@MickJav


That function has a problem handing boolean variables because of the line
Code:
If varToTest Then IsNothing = False
If the passed variable is False, then the function gives the variable as missing.


Note that in #4

Code:
If Nz(TestField,””)=“”)
will be true for both a null and a ZLS
 
It's always worked but I don't use it to test boolean I alway give mine a default of false
 

Users who are viewing this thread

Back
Top Bottom