Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2013, 07:36 AM
lhuffst lhuffst is offline need help understanding mailmerge code Windows 7 64bit need help understanding mailmerge code Office 2010 32bit
Novice
need help understanding mailmerge code
 
Join Date: Feb 2013
Posts: 1
lhuffst is on a distinguished road
Default need help understanding mailmerge code

I am new to mailmerge and do not understand all of the following code.
It is supposed to return the first day of the next month of the formfield (orgdate). If the date is null then use current date.
What I get is the first date of the last month

When I went through the code, I realized that I didn't really understand all of the lines of code and am hoping someone can explain it to me, particularly the mod statements.
Code:
Effective Date: {QUOTE{QUOTE
{SET ORGDATE {IF{ MERGEFIELD "InvoiceDate"}="" {MERGEFIELD "Date_Stamp" \@ 
M/d/yyyy} {MERGEFIELD "InvoiceDate" \@ M/d/yyyy}} }
{SET Delay 1}
{SET mm {=MOD(ABS({ORGDATE\@M}+Delay+11),12)+1}}
{SET yy{=INT({ORGDATE}\@ YYYY}+(dELAY+{ORGDATE \@ M}-1)/12)}}
{SET dd{=IF(({ORGDATE}\@ 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)+{ORGDATE\@ d}>30)>1,30,{
ORGDATE \@ d}))}}
"{delay}-{mm}-{yy}" \@ "M/d/yyyy"}}
Thanks
Reply With Quote
  #2  
Old 02-13-2013, 05:19 PM
macropod's Avatar
macropod macropod is offline need help understanding mailmerge code Windows 7 64bit need help understanding mailmerge code Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Your OrgDate test doesn't say "If the date is null then use current date". What it says is "If the Invoice date is null then use date_stamp date, otherwise, use the Invoice date" - both as the basis for doing a date calculation.

Be that as is may, you're using entirely the wrong field code if all you want is the first day of the next month. For that the field code would be:
Code:
{QUOTE
{SET StartDate {IF{MERGEFIELD InvoiceDate}= "" {MERGEFIELD Date_Stamp \@ M/d/yyyy} {MERGEFIELD InvoiceDate \@ M/d/yyyy}}}
{SET Delay 1}
{SET m{=MOD({StartDate\@ MM}+Delay+11,12)+1}}
{SET y{=INT({StartDate\@ yyyy}+(Delay+{StartDate\@ M}-1)/12)}}
"{m}-1-{y}" \@ "M/d/yyyy"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help understanding mailmerge code Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 8 02-11-2013 04:40 AM
need help understanding mailmerge code Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 13 05-29-2012 02:04 PM
need help understanding mailmerge code Mailmerge dkub Mail Merge 35 12-07-2011 11:35 PM
Help with mailmerge??? foxtrot1981 Mail Merge 0 12-03-2010 08:21 AM
Understanding .docx XML tags for better performance RithanyaLaxmi Word 1 03-08-2010 01:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft