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
objBirthDate = ""
ActiveDocument.FormFields("Birthdate".Select 'move insertion back to the form field
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
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
objBirthDate = ""
ActiveDocument.FormFields("Birthdate".Select 'move insertion back to the form field
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