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

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
 
D

David F

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
 
D

David F

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
 

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