How to do date validation in MS Word 2000 using VBA

B

Bon

Dear all

I have an textbox field for user entering date. But, I want to do date
validation. (i.e. if the input date is before or equal to Today date,
it will prompt a "Invalid inputted date" message) What commands I have
to use for the date comparision? Could anyone give me some hints on
doing it? Any sample code?

Thank you very much

Bon
 
D

Doug Robbins - Word MVP

With ActiveDocument.FormFields("dateformfield")
If IsDate(.Result) Then
If DateDiff("d", Format(Now, "yyyyMMdd"), Format(.Result,
"yyyyMMdd")) < 1 Then
MsgBox "You must enter a future date."
Exit Sub
End If
Else
MsgBox "You did not enter a valid date."
Exit Sub
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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