Return to a form field to re-enter data

R

ronben

Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel I have a form field for entering date of birth but wish to trap an inadvertent future date; i.e., the date of birth was entered incorrectly and cannot be used to calculate age using a macro that activates upon exit from the field. The bookmark for that field is BirthDate. The code snippet I am using is:

Dim objBirthDate as FormField
Set objBirthDate = ActiveDocument.FormFields("BirthDate")

'the code proceeds to calculate age as difference in months (using DateDiff) based on the 'difference between objBirthDate and Date.
'When date of birth is actually a date in the future. the code returns a negative number for the 'difference in months.

If DiffMonths < 0 then
&nbsp;&nbsp;objBirthDate = &quot;&quot;
&nbsp;&nbsp;ActiveDocument.FormFields(&quot;Birthdate&quot;).Select 'move insertion back to the form field
&nbsp;&nbsp;Exit Sub
End if

When the code quits and the form re-displays, the incorrect date in the form field is 'erased' but the insertion, instead of returning to this field, has moved to the next field in succession.

Basically, I am stuck.

Ron
 

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