NUll etc testing for on forms?????

paulmcdonnell

Ready to Help
Local time
Today, 18:43
Joined
Apr 11, 2001
Messages
167
Guys,

I have had this little gremlin for some time now.

I want to test in code if a form value has no entry, ie nothing has been put into it. (in basic terms)

I've tried if text1="" then ...

and
if text1 is null then...

and if text1 is empty then...

but either the condition isn't met or I get object required message...


What is a good if-then test for testing if a control has nothing in it?

What am I overlooking?

CHeers
PAUL!!!!!!!!!!!
 
Cheers John that worked...

I Should have known that....!

Cheers
Paul

(I like the flag..)
 
IsNull will only detect null fields. I had this problem when users entered and then deleted the field leaving a "" string which wasn't detected with the IsNull function. I found a small routine which I use as a function which detects empty fields of all types -

It goes like this -

' Tests for a "logical" nothing based on data type
' Empty and Null = Nothing
' Number = 0 is Nothing
' Zero length string is Nothing
' Date/Time is never Nothing

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

Create a new module and call the function IsNothing()
 

Users who are viewing this thread

Back
Top Bottom