Text field is empty check

H

Harmannus

Hallo,

I can't get the below code to work. The field InvoiceNumber is a text field
and if it has no value / empty the LockUnlock is False.

If Me![Invoicenumber] = Not Null Then
Me.AllowDeletions = False
LockUnlock True
Else
Me.AllowDeletions = True
LockUnlock False
End If

Any suggestion on the syntax?

Regards,

Harmannus
 
A

Adrian Jansen

The reasoning is that no value is ever equal to Null, not even a Null. So
you cant do the test the way you had it. What you do is test for the value
not being a Null:

If not isnull(me!Invoicenumber) then...


In the case of a text field, this may also fail for a non obvious reason
too. The value in the textbox could be a zero length string, so not
visible, but also not null.

A somewhat better test is

len(nz(me!Invoicenumber,"")) > 0

ie make the value a zero length string if its a null, then test > zero
length.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
D

Douglas J. Steele

If Not IsNull(Me![Invoicenumber]) Then

or

If IsNull(Me![Invoicenumber]) = False Then
 
H

Harmannus

Hallo,

Thanx for the quick reply!

Works great. I will buy a VB book :)

Regards,

Harmannus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top