Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2004

Tip: Looking for answers? Try searching our database.

Choosing a merge value by code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dinsdale - 12 Jul 2004 10:21 GMT
People,

I have a couple of templates in which usually the value of a field is
pulled in automatically. Now the organisation wants to have the
situation whereby if the value in a specific field is blank, the value
is replaced by the value from another source field. For example, if the
value for the field named Bill To/Contact is normally the contact
person's name, we want the field source to be the company name if there
is no contact person.

So can someone provide me with a hint of how to do this?

Thanks

Andrew
Greg - 12 Jul 2004 12:54 GMT
Dinsdale,

A better answer is likely to come along, but some
variation of an IF field should work e.g.;

[ IF {MERGEFIELD Contact } = ""{MERGEFIELD CompanyName}
{MERGEFIELD Contact}}

>-----Original Message-----
>People,
[quoted text clipped - 13 lines]
>Andrew
>.
Dinsdale - 13 Jul 2004 08:32 GMT
Greg,

Thanks heaps. Sounds good and easy to implement (I hope - I've said that
before and lost even more hair).

Andrew

> Dinsdale,
>
[quoted text clipped - 40 lines]
>>Andrew
>>.
Dinsdale - 13 Jul 2004 08:58 GMT
Greg,

I knew it! It doesn't seem to want to work - I suspect because the field
is referring to itself? I'm wondering if I can do this in the
originating VBA code.

Andrew

> Dinsdale,
>
[quoted text clipped - 40 lines]
>>Andrew
>>.
Peter Jamieson - 13 Jul 2004 09:14 GMT
The self-reference thing should not be an issue. The precise syntax may be
critical here.

1. All the {} must be the special field code braces that you can insert
using ctrl-F9

2. I would always ensure there are spaces between the various items in the
field, and quote the two results i.e.

{ IF { MERGEFIELD Contact } = "" "{ MERGEFIELD CompanyName }" "{MERGEFIELD
Contact}" }

3. Although I do not believe it makes any difference in most (if not all)
cases, I program defensively and quote any field I'm comparing with "", i.e.

{ IF "{ MERGEFIELD Contact }" = "" "{ MERGEFIELD CompanyName }" "{MERGEFIELD
Contact}" }

Other than that, it is worth checking exactly what { MERGEFIELD Contact } is
returning. If it returns even a single space, the comparison will fail.

Signature

Peter Jamieson

> Greg,
>
[quoted text clipped - 47 lines]
> >>Andrew
> >>.
Dinsdale - 13 Jul 2004 11:07 GMT
Thanks Peter. I will persevere.

Andrew

> The self-reference thing should not be an issue. The precise syntax may be
> critical here.
[quoted text clipped - 16 lines]
> Other than that, it is worth checking exactly what { MERGEFIELD Contact } is
> returning. If it returns even a single space, the comparison will fail.
Dinsdale - 15 Jul 2004 07:25 GMT
Peter and Greg,

It works! The reason it didn't work earlier was I forgot about the
ctrl-F9 bit and simply did a cut and paste. Doh!!!

Thanks again.

Andrew

> The self-reference thing should not be an issue. The precise syntax may be
> critical here.
[quoted text clipped - 16 lines]
> Other than that, it is worth checking exactly what { MERGEFIELD Contact } is
> returning. If it returns even a single space, the comparison will fail.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.