Unbound Text Box Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
Back
Top