Choosing a merge value by code

D

Dinsdale

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
 
G

Greg

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}}
 
D

Dinsdale

Greg,

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

Andrew
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,

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
.
 
D

Dinsdale

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,

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,

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
.
 
P

Peter Jamieson

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.

--
Peter Jamieson

Dinsdale said:
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,

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,

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
.
 
D

Dinsdale

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
 

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