Isnull not working? (1 Viewer)

alcifer_c

Registered User.
Local time
Today, 03:46
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?
 

RuralGuy

AWF VIP
Local time
Yesterday, 20:46
Joined
Jul 2, 2005
Messages
13,825
It could also be a ZLS (zero length string) "".
 

alcifer_c

Registered User.
Local time
Today, 03:46
Joined
Jun 3, 2002
Messages
42
zero length string

What's the difference and how does one check for that?
 

ghudson

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 8, 2002
Messages
6,194
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.
 

RuralGuy

AWF VIP
Local time
Yesterday, 20:46
Joined
Jul 2, 2005
Messages
13,825
If Len(Me.Callers1!ContactFirstName & "") > 0 Then MsgBox Me.Callers1!ContactFirstName
 

arichins

Registered User.
Local time
Yesterday, 19:46
Joined
Apr 9, 2009
Messages
95
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.
 

Xproterg

Registered User.
Local time
Yesterday, 19:46
Joined
Jan 20, 2011
Messages
67
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.
 

1DMF

Registered User.
Local time
Today, 03:46
Joined
Oct 20, 2011
Messages
14
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.
 

RuralGuy

AWF VIP
Local time
Yesterday, 20:46
Joined
Jul 2, 2005
Messages
13,825
What I posted in post #5 will handle both a ZeroLengthString (ZLS) and a Null.
 

1DMF

Registered User.
Local time
Today, 03:46
Joined
Oct 20, 2011
Messages
14
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
 

VilaRestal

';drop database master;--
Local time
Today, 03:46
Joined
Jun 8, 2011
Messages
1,046
What is Me.Callers1!ContactFirstName?

Either it should be:

Me!ContactFirstName

or

Me.Callers1.Form!ContactFirstName if Callers1 is a subform
 

spikepl

Eledittingent Beliped
Local time
Today, 04:46
Joined
Nov 3, 2010
Messages
6,142
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.
 

VilaRestal

';drop database master;--
Local time
Today, 03:46
Joined
Jun 8, 2011
Messages
1,046
Oh yeah, didn't notice the dates. :s

And verily the thread rose from the dead
 

Users who are viewing this thread

Top Bottom