Text field is empty check

  • Thread starter Thread starter Harmannus
  • Start date Start date
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
 
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
 
If Not IsNull(Me![Invoicenumber]) Then

or

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

Thanx for the quick reply!

Works great. I will buy a VB book :-)

Regards,

Harmannus
 
Back
Top