Isnull not working?

alcifer_c

Registered User.
Local time
Today, 17:41
Joined
Jun 3, 2002
Messages
42
Code:
If Not IsNull(Me.Callers1!ContactFirstName) Then MsgBox Me.Callers1!ContactFirstName.Value

Generating error message:
You entered an expression that has no value.

The form is open and has no value... but the isnull should take care of this, no?
 
zero length string

What's the difference and how does one check for that?
 
Code:
If Not IsNull(Me.Callers1!ContactFirstName) or Not Me.Callers1!ContactFirstName = "" Then MsgBox Me.Callers1!ContactFirstName.Value
You will get an empty string if the user started to key something in the text box then cleared it out by using the delete key or backspace key for the text field is no longer Null but it is still "dirty" but empty.
 
If Len(Me.Callers1!ContactFirstName & "") > 0 Then MsgBox Me.Callers1!ContactFirstName
 
Code:
If Not IsNull(Me.Callers1!ContactFirstName) or Not Me.Callers1!ContactFirstName = "" Then MsgBox Me.Callers1!ContactFirstName.Value
You will get an empty string if the user started to key something in the text box then cleared it out by using the delete key or backspace key for the text field is no longer Null but it is still "dirty" but empty.


I have the exact same problem as the original poster, and this code does not work. It will throw an error when you try to determine of the field is a zero length string "", saying it has no value.
 
There are various functions that pertain to different data types... for instance, dates are considered integers when dealing with their values. So instead of checking to see if it's null, you'd have to check to see if it's value is equal to zero.

IsEmpty
IsNull
is <> ""
is <> 0

All of the above are used to deal with empty strings. There are a few more, so I hope this helps.
 
I have the same problem
Code:
If IsNull(Me.Reason) Or Me.Reason = "" Then
    MsgBox "You must set reason for termination first!"
    Exit Sub
End If

This doesn't work?

I have found replacing all uses of IsNull or = "" with
Code:
If nz(Me.Reason,"") = "" Then
    MsgBox "You must set reason for termination first!"
    Exit Sub
End If

Resolves the problem.
 
What I posted in post #5 will handle both a ZeroLengthString (ZLS) and a Null.
 
I don't agree , i agree with post #6
It will throw an error when you try to determine of the field is a zero length string
 
What is Me.Callers1!ContactFirstName?

Either it should be:

Me!ContactFirstName

or

Me.Callers1.Form!ContactFirstName if Callers1 is a subform
 
LOL. I think that problem of 6 years ago is long gone. But you are right.

And the "solution" posted in #4 is wrong, because an OR in VBA evaluates both sides.
 
Oh yeah, didn't notice the dates. :s

And verily the thread rose from the dead
 

Users who are viewing this thread

Back
Top Bottom