Maria Cristina
New Member
- Joined
- Mar 18, 2016
- Messages
- 1
Please I need help with the code
I need a mail merge word document to send to each of the different customers. The letter has different paragraphs depending on the status and office they apply for. Most of them will give reports and they are also based on the office and status they have, so some of them will need 3 reports when other may need 15 reports.
I have a query that merges all of the information, but I will have rows as they customer has reports were this will be the only information for that customer that is different in the table.
I get the information up to the list of reports, after that I get the information for the next customer. I get the AB, PA, TR, ContactP and Cert. No. for the next record. I know that it must be on the (" ""}{Set VRID1"{MERGEFIELD VRID}"}{IF {VRID2} <> {VRID1}") but every time I change it then I don't get anything after the reporting dates.
After looking on WD2000: How to Work Around Duplicate Names in Mail Merge Data I came up with:
Open the Word Document and in Mail merge selected Directory, selected the query from the database and sort it by Customer ID No. and by Report due date.
{ IF {MERGESEQ}="1" "{MERGEFIELD VRID}
{MERGEFIELD LETTERDATE}
{ADDRESSBLOCK}
{MERGEFIELD GREETINGNAME}
{MERGEFIELD DQ1}{MERGEFIELD EU1}{MERGEFIELD DQENREP1}{MERGEFIELD DQEREP1}{MERGEFIELD BNNREP1}{MERGEFIELD BNREP1}
{MERGEFIELD CAMPR} {MERGEFIELD CAMPF} {MERGEFIELD CAMPT} {MERGEFIELD CAMPD}
" ""}{SET VRID1}"{MERGEFIELD VRID}"}{IF {VRID2}<>{VRID1}"
{MERGEFIELD AB}
{MERGEFIELD PA}
{MERGEFIELD TR}
If you have any questions, please do not hesitate to contact {MERGEFIELD CONTACTP}
{MERGEFIELD PERSONSIGNING}
{MERGEFIELD TITLEPERSONSIG}
Certified No: {MERGEFIELD CERTNOALL}
-----------PAGE BREAK----------------------------------
{MERGEFIELD LETTERDATE}
{ADDRESSBLOCK}
{MERGEFIELD GREETINGNAME}
{MERGEFIELD DQ1}{MERGEFIELD EU1}{MERGEFIELD DQENREP1}{MERGEFIELD DQEREP1}{MERGEFIELD BNNREP1}{MERGEFIELD BNREP1}
{MERGEFIELD CAMPR} {MERGEFIELD CAMPF} {MERGEFIELD CAMPT} {MERGEFIELD CAMPD}
{MERGEFIELD PERIODNAME} {MERGEFIELD STARTDT} {MERGEFIELD ENDDT} {MERGEFIELD RPTDATE}" "
{MERGEFIELD PERIODNAME} {MERGEFIELD STARTDT} {MERGEFIELD ENDDT} {MERGEFIELD RPTDATE}"
Certified No: {MERGEFIELD CERTNOALL}"}{SET VRID2 "{MERGEFIELD VRID}"}
I need a mail merge word document to send to each of the different customers. The letter has different paragraphs depending on the status and office they apply for. Most of them will give reports and they are also based on the office and status they have, so some of them will need 3 reports when other may need 15 reports.
I have a query that merges all of the information, but I will have rows as they customer has reports were this will be the only information for that customer that is different in the table.
I get the information up to the list of reports, after that I get the information for the next customer. I get the AB, PA, TR, ContactP and Cert. No. for the next record. I know that it must be on the (" ""}{Set VRID1"{MERGEFIELD VRID}"}{IF {VRID2} <> {VRID1}") but every time I change it then I don't get anything after the reporting dates.
After looking on WD2000: How to Work Around Duplicate Names in Mail Merge Data I came up with:
Open the Word Document and in Mail merge selected Directory, selected the query from the database and sort it by Customer ID No. and by Report due date.
{ IF {MERGESEQ}="1" "{MERGEFIELD VRID}
{MERGEFIELD LETTERDATE}
{ADDRESSBLOCK}
{MERGEFIELD GREETINGNAME}
{MERGEFIELD DQ1}{MERGEFIELD EU1}{MERGEFIELD DQENREP1}{MERGEFIELD DQEREP1}{MERGEFIELD BNNREP1}{MERGEFIELD BNREP1}
{MERGEFIELD CAMPR} {MERGEFIELD CAMPF} {MERGEFIELD CAMPT} {MERGEFIELD CAMPD}
" ""}{SET VRID1}"{MERGEFIELD VRID}"}{IF {VRID2}<>{VRID1}"
{MERGEFIELD AB}
{MERGEFIELD PA}
{MERGEFIELD TR}
If you have any questions, please do not hesitate to contact {MERGEFIELD CONTACTP}
{MERGEFIELD PERSONSIGNING}
{MERGEFIELD TITLEPERSONSIG}
Certified No: {MERGEFIELD CERTNOALL}
-----------PAGE BREAK----------------------------------
{MERGEFIELD LETTERDATE}
{ADDRESSBLOCK}
{MERGEFIELD GREETINGNAME}
{MERGEFIELD DQ1}{MERGEFIELD EU1}{MERGEFIELD DQENREP1}{MERGEFIELD DQEREP1}{MERGEFIELD BNNREP1}{MERGEFIELD BNREP1}
{MERGEFIELD CAMPR} {MERGEFIELD CAMPF} {MERGEFIELD CAMPT} {MERGEFIELD CAMPD}
{MERGEFIELD PERIODNAME} {MERGEFIELD STARTDT} {MERGEFIELD ENDDT} {MERGEFIELD RPTDATE}" "
{MERGEFIELD PERIODNAME} {MERGEFIELD STARTDT} {MERGEFIELD ENDDT} {MERGEFIELD RPTDATE}"
Certified No: {MERGEFIELD CERTNOALL}"}{SET VRID2 "{MERGEFIELD VRID}"}