Thread: [Solved] Adding months to a Date
View Single Post
 
Old 10-03-2011, 05:20 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tsindos,

That code comes from my Microsoft Word Date Calculation Tutorial, at:
http://lounge.windowssecrets.com/ind...owtopic=249902
or
http://www.gmayor.com/downloads.htm#Third_party

It would appear that you've tried to combine a field code from the tutorial that used error-checking with the field for adding months to a date, and got some of the syntax wrong - specifically, a '(' before the first 'Delay' reference. If your formfield has data entry validation, you don't need the additional error-checking code, and it can be reduced to:
{QUOTE
{SET mm{=MOD(ABS({StartDate \@ M}+Delay+11);12)+1}}
{SET yy{=INT({StartDate \@ yyyy}+(Delay+{StartDate \@ M}-1)/12)}}
{SET dd{=IF(({StartDate \@ d}>28)*(mm=2)=1;28+((MOD(yy;4)=0)+(MOD(yy;400)=0)-(MOD(yy;100)=0));IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+( {StartDate \@ d}>30)>1;30;{StartDate \@ d}))}}
"{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy" \* Charformat}

Note that I've bolded the 'Q' in 'QUOTE' and added a Charformat switch. That's the correct way to alter the field's formatting - not by trying to apply bold formatting to the lot (which often adds numerous unhelpful Mergeformat switches).

Also, your formfields need the 'calculate on exit' property set, otherwise, the calculation won't occur.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote