Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for Nulls or zero length

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
I have written a function that successfully checks the contents for all the non-alphameric characters on the keyboard and return a True or False. I get a runtime error if the textbox is empty - invalid use of null. Iam sure the answer involves NZ function, but can't get it right. Just want to check for null, and if not do the function, and if null don't do the function.
I ahve scanned the web and tried several way, but to no avail.

Thanks in advance

jpl
 
you are probably doing

if something = null

The above statement will never be true if if "something" is null

test

Public Sub tstnull()
Dim x As Variant
x = Null
If x = Null Then
MsgBox "x = null"
Else
MsgBox "x is not null"
End If
End Sub

what is the message. X is not null when in fact it is null

x = null
if isnull(x)...

or better to test for null, empty string, or empty spaces

if trim(sometextbox & " ") =
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top