Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50117

isDate - excel form -VBA

$
0
0
Hi there,

I am wanting to add some data validation to my excel form. It is meant to be a check on date.

Code:

Private Sub textbox17_gp_date_change()
If Me.TextBox17_test_Date.Value = vbNullString Then Exit Sub
    If Not IsDate(Me.TextBox17_test_Date.Value) Then
        MsgBox "Sorry, only date format in dd/mm/yyyy", vbCritical, "Data Validation"
        Me.TextBox17_test_Date = vbNullString
    End If
End Sub

when I run the form by putting in say...04/01/2012, it gives me that prompt saying invalid date.

Is there a way around this?

Thanks

Viewing all articles
Browse latest Browse all 50117