text box length

S

Souris

I wanted to verify the length of text box.
If the text box is empty do something

I use following VBA code.

If Len(txtMyText) = null then
MyFunction
else
MyFunction1
end if


The problem is when the ttext box is empty then the len function return null.
I got Null = Null, but VBA execute Myfunction1 not MyFunction.

Any suggestion?
Any informaiton is great apprecitaed,
 
K

Ken Snell [MVP]

Len(Me.TextBoxName.Value & "") = 0

Above will tell you if the textbox is empty, regardless of whether it's a
null value or an empty string.
 
J

Joerg Ackermann

Souris said:
I wanted to verify the length of text box.
If the text box is empty do something

I use following VBA code.

If Len(txtMyText) = null then
MyFunction
else
MyFunction1
end if


The problem is when the ttext box is empty then the len function
return null. I got Null = Null, but VBA execute Myfunction1 not
MyFunction.

If IsNull(txtMyText) then
....


Acki
 
T

TPratt

Instead of testing the length why not check to see if the value is Null?

If IsNull(txtMyText.Value) then
 
Top