Unbound Text Box Value

M

MJatAflac

What is the initial value of an unbound text box? I have tried evaluating for
Is Null, Is Empty and "" but these don't seem to be true.

The reason I ask is that I want to be able to check to see if a user has
input anything in the textbox and message them if they didn't but when I use:

if textbox.value Is Null Then
if textbox.value Is Empty Then
if textbox.value = "" then

I don't get a "hit"

any guidance?

thanks,

Michael Joyce
 
K

Klatuu

The default value for an unbound text box is Null. If you are using the code
you posted, it will not work. The correct syntax is:

If IsNull(Me!txtSomething) Then
'The control has nothing in it
End If

The IsEmpty() function only works for Variant data types.
 
T

Tim Ferguson

What is the initial value of an unbound text box? I have tried
evaluating for Is Null, Is Empty and "" but these don't seem to be
true.

If the textbox still has the focus you can use:

If Len(Me!MyTextBox.Text)=0 Then
' it's empty


If it doesn't have the focus, you have to use the Value property, which
is a variant

If IsNull(Me!MyTextBox.Value) Then
' it's empty

If you don't specify the property, you get the value, so you can use

If IsNull(Me!MyTextbox) Then

Hope that helps


Tim F
 

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