How do I test for a null value in a text box?

  • Thread starter Thread starter Ken Snell
  • Start date Start date
K

Ken Snell

Chances are, you don't have a Null value in the textbox but perhaps an empty
string?

Use this code (assumes that a decimal separator is a period):

If Len(Me.txtDateEnd.Value & "") = 0 Then
MsgBox "You must enter a value!"
ElseIf IsNumeric(Me.txtDateEnd.Value) = True And _
InStr(Me.txtDateEnd.Value, ".") > 0 Then
MsgBox "You must enter an integer value!"
End If
 
I have a text box that should contain an interger value. How can I test
using VBA to make sure it does?

The folloiwng will not work:

If IsNull(txtDateEnd.Value) Then
MsgBox "null"
End If

Thanks for any ideas.
Dave
 
Thanks!


Ken Snell said:
Chances are, you don't have a Null value in the textbox but perhaps an empty
string?

Use this code (assumes that a decimal separator is a period):

If Len(Me.txtDateEnd.Value & "") = 0 Then
MsgBox "You must enter a value!"
ElseIf IsNumeric(Me.txtDateEnd.Value) = True And _
InStr(Me.txtDateEnd.Value, ".") > 0 Then
MsgBox "You must enter an integer value!"
End If
 
Back
Top