mail merge if field nesting

B

Barry

I use Word 2000 and have a mail merge set up. I'd like to add a line
to the label using an if field. The if statement should look at the
same Acess database used for the mail merge, at a particular field and
if that field is 12, I want December 31, 2004 to appear, if the Access
field is 11, I want November 30, 2004 to appear, if the Access field
is 10, I want October 31, 2004 to appear, etc, etc. Is this possible?
Is their a limit on the number of if fields on a label line? I tried
writing the if statement but after 4 of them it didn't seem to let me
add the 8 others.

Barry
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Barry,

I would suggest that it will be much easier to use a Query in Access to
create those dates. If the number was in a field named Test1, the following
expression in the Query would return the dates that you want:

IIf([Test1]<12,DateAdd("d",-1,Format(1 & "/" & ([Test1]+1) & "/" &
2004,"mmmm d, yyyy")),DateAdd("d",-1,Format(1 & "/" & 1 & "/" & 2005,"mmmm
d, yyyy")))

That's a lot easier to create than a whole lot of nested IF statements in
Word. Databases should be used for manipulating data, not word processors.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
G

Graham Mayor

While Doug's solution is altogether more elegant, you don't have to nest the
fields, placing the conditional statements on the same line with no space
between them. {IF {Mergefield Fieldname} = 12 "December 31, 2004" ""}{IF
{Mergefield Fieldname} = 11 "November 30, 2004" ""} etc should work.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
B

Barry

Graham Mayor said:
While Doug's solution is altogether more elegant, you don't have to nest the
fields, placing the conditional statements on the same line with no space
between them. {IF {Mergefield Fieldname} = 12 "December 31, 2004" ""}{IF
{Mergefield Fieldname} = 11 "November 30, 2004" ""} etc should work.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


Okay,

Both of the replies worked. Now I'm wondering if I can calculate the
year after the date. For example, let's say the date is December 31,
is there any way to calculate 1) the current year (2003) and 2) the
next year (2004) so it is automatically entered after the date? If
this is possible, I would not have to change the 'year' in the query
or the 'ifs' every year.

Barry
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Barry,

In the Access query method, you can use Format(Date$(),"yyyy") to get the
current year e.g. 2003 then you can use the DateAdd() function to add years
to it as required.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
B

Barry

Okay,

Both of the replies worked. Now I'm wondering if I can calculate the
year after the date. For example, let's say the date is December 31,
is there any way to calculate 1) the current year (2003) and 2) the
next year (2004) so it is automatically entered after the date? If
this is possible, I would not have to change the 'year' in the query
or the 'ifs' every year.

Barry


What I did to solve this problem is create a custom document property
called 'current year' and 'next year' and assigned those the requisite
year. I then put the document property field in the document. Seems
to work to my satisfaction.

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top