Date check

S

Stanley

I have a text field that I type a date into. I want to check to set if the
date is valid.
The code below doesn't come close. Any way to do this? I am using Word 2003
Thanks,
Stanley

Sub ExitLastDayOfAttend()
Set vtxtLastDayOfAttend = ActiveDocument.FormFields (I want to get the value
of the field when I exit it.
If Not IsDate(vtxtLastDayOfAttend) Then
MsgBox "The date entered is invalid.", vbExclamation, "Reenter Date"
vtxtLastDayOfAttend = "mm/dd/yy" (hereI want to set the default value of
the field back to mm/dd/yy
End If
End Sub
 
F

Fumei2 via OfficeKB.com

1. You are using Set vtxtLastDayOfAttend. What is this declared as?

2. Is the formfield set as a Date type? have you set the Date format the
way you want?

If you have, then if the "wrong" input is enterd, there is an error message.
 
S

Stanley

I am putting the macro in a template and I am looking at a text box in it.
The properties, events and methods are different from those in a form (have
onexit and onenter events for examples and I can set a default value).
My problem is putting the code I want in the template.
Thanks,
Stanley
 

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