Form Fields reset when printing.

I created a form where the user can complete various form fields (legacy) and they each "calculate on exit" to allow the additional form fields in the form to update according to the data entered and create the desired result:

  • The date is calculated on each page once or twice to become a future date
  • The names and addresses are "ref" copied on every other page
  • and a table is created at the end documenting the specific dates

Everything works as desired until I go to print it.  whether I use the "quick print" feature or the Ctrl+P dialog, what prints is the wrong date on every page except the first two.  

The situation is quite frustrating.  

Answer
Answer

Rather that use the field constructions to set the future dates, run the following macro On Exit from the FmDate FormField

 

Sub SetDates()

Dim myDate As Date

'Set the start date with bookmarked text

With ActiveDocument

    If IsDate(.FormFields("FmDate").Result) Then

        myDate = .FormFields("FmDate").Result

        .Variables("Date1").Value = Format(DateAdd("d", 1, myDate), "M/d/yyyy")

        .Variables("Date2").Value = Format(DateAdd("d", 2, myDate), "M/d/yyyy")

        .Variables("Date3").Value = Format(DateAdd("d", 15, myDate), "M/d/yyyy")

        .Variables("Date4").Value = Format(DateAdd("d", 16, myDate), "M/d/yyyy")

        .Variables("Date5").Value = Format(DateAdd("d", 17, myDate), "M/d/yyyy")

        .Variables("Date6").Value = Format(DateAdd("d", 50, myDate), "M/d/yyyy")

        .Variables("Date7").Value = Format(DateAdd("d", 51, myDate), "M/d/yyyy")

        .Variables("Date8").Value = Format(DateAdd("d", 52, myDate), "M/d/yyyy")

        .Range.Fields.Update

    Else

        MsgBox "You did not enter a valid date."

    End If

End With

End Sub

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 14, 2025 Views 247 Applies to: