MERGEFIELD on Condition

O

omsoft

I have a table in mail merge which is being populated by an Access table.
It has tree columns - product, region, revenue and five rows.
I want to create a mergefield where if revenue = 0 then leave product and
region blank.

I have added the field as below. But it does not work. Can someone please
tell me what I am doing wrong? Thanks much.

{IF{MERGEFIELD rev = 0 """" {MERGEFIELD prod}}}
 
P

Peter Jamieson

Something more like...

{ IF { MERGEFIELD revenue } = 0 "" "{ MERGEFIELD prod }" }

All the {} have to be the special field code brace pairs that you can
insert using ctrl-F9

Peter Jamieson

http://tips.pjmsn.me.uk
 
O

omsoft

Thanks Peter, I did exactly as you mentioned, but I could not really make it
work. May be because my column order is product, region and revenue and so
when I am populating product, revenue is still not populated? Does the order
matter when evaluating condition?
 
D

Doug Robbins - Word MVP

Do you have a { MERGEFIELD revenue } field in the document where you want
the revenue to appear (That is one outside of the If...then...Else field
construction, which only controls the insertion of the product. You need a
similar If...then...Else field construction for the region where you want
that to appear if the revenue is not zero.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
O

omsoft

Thanks Doug, I do have a mergefield rev outside the table.
The letter is name, address, etc. at the top followed by a three column
table where the columns are product, region and revenue in that order. I do
not know how many rows of data this table will have but I limit it at 5 and
create a new form if > 5.

So the product one is as below:

{if {mergefield rev} <> 0 {mergefield prod} ""}
The region also would be similar except that it would specify regn instead
of prod.
And the revenue one just says {mergefield rev}.

IN the table prior to that, I am forcibly setting revenue to 0 if it is null
to avoid complications of checking null or empty string.

Thanks.
 
O

omsoft

Thanks Peter. I am getting all correcting values, that is not a problem.
Sorry if I did not clarify. I want to add this condition, so if revenue is 0,
the product and region fields become blank.

When I add a field, { MERGEFIELD revenue }, I get revenue amount, and in
those blank rows I get nothing (empty string).
 
O

omsoft

Thanks Doug for the links. I had seen these earlier but this may be too
complex for the users to deal with later on (once I have done my task and
gone away at contract-end).

The source data table in Access is set up so that each row includes customer
name, address, etc. and then five sets of product, region and revenue. And I
create one letter for each row of data. So a customer with more than five
rows of data will get more than one letter.
 
P

Peter Jamieson

In that case you probably need:

{ IF { MERGEFIELD revenue } = "" "" "{ MERGEFIELD prod }" }
or possibly even
{ IF "{ MERGEFIELD revenue }" = "" "" "{ MERGEFIELD prod }" }

Peter Jamieson

http://tips.pjmsn.me.uk
 
O

omsoft

Thanks Peter, that works.Thanks a million.
I should have been checking for empty string rather than 0.
 
D

Doug Robbins - Word MVP

That is not the way that the database should be set up.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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