Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] FuriousCanis@googlemail.com is offline
external usenet poster
 
Posts: 3
Default Conditional create table

Hi All

I'm a complete beginnier at mail merges so please be gentle.

I've inherited a mail merge were we want to have a formatted table
only if there is data present. The number of rows in the table
(excluding header) can be between 0 and 3, if its 0 then dont show the
table, otherwise only the rows with data.

Any help or pointers would be very much appreciated.

cheers

Keith
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Conditional create table

This sounds like a list sorted by category -
http://support.microsoft.com/?kbid=294686

Fellow MVP 'macropod' has posted a tutorial on this, with working field
codes and a sample Excel data source which you can download from my website
http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip Do read the
instructions BEFORE jumping in.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



wrote:
Hi All

I'm a complete beginnier at mail merges so please be gentle.

I've inherited a mail merge were we want to have a formatted table
only if there is data present. The number of rows in the table
(excluding header) can be between 0 and 3, if its 0 then dont show the
table, otherwise only the rows with data.

Any help or pointers would be very much appreciated.

cheers

Keith



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Conditional create table

How to do this depends on precisely how you determine how many rows you
need and what should be in them. If te table only relates ot a single
data source, then it would typically be something like
a. If fielda is non-blank, insert a row containing fielda
b. if fieldb is non-blank, insert a row containing fieldb
c. if fieldc is non-blank, insert a row containing fieldc

In that scenario, there are 7 possible tables that actually contain
anything and you could
a. insert a nested IF field that contains each of the 7 tables, e.g.

{ IF "{ MERGEFIELD fielda }" = ""
"{ IF "{ MERGEFIELD fieldb }" = ""
"{ IF "{ MERGEFIELD fieldc }" = "" ""
"put the table and fields for a table with a fieldc row only here" }"
"{ IF "{ MERGEFIELD fieldc }" = ""
"put the table and fields for a table with a fieldb row only here"
"put the table and fields for a table with fieldb and fieldc here" }"
"similar stuff for the case where fielda is non-blank" }

All the {} have to be the special field code braces that you can insert
using ctrl-F9. You can toggle bewteen field codes and results using
alt-F9. You can put text, complete tables, and field codes inside the IF
"results" as I have indicated.

Probably slightly simpler in some respects would be to calculate a
"table number", e.g. where fielda "" counts 4, fieldb blank counts
2 and fieldc "" counts 1. Then table 6 would be the table with
non-blank fielda and fieldb, but blank fieldc.

You could do that as follows:

{ SET tablenumber { =4*{ COMPARE "{ MERGEFIELD fielda }" "" }
+ 2*{ COMPARE "{ MERGEFIELD fieldb }" "" }
+ { COMPARE "{ MERGEFIELD fieldc }" "" } }

Then you can have a separate IF for each table and avoid nesting, e.g.

{ IF { REF tablenumber } = 1 "table and fields for fieldc only" ""
}{ IF { REF tablenumber } = 2 "table and fields for fieldb only" ""
}{ IF { REF tablenumber } = 3 "table and fields for fieldb and fieldc
only" ""
}

etc.

Of course /your/ conditions could be more complex (IMO separating a
calculation based on the conditions from the actual business of the
layout is probably even more useful in that case) or you may be getting
data from multiple records, in which yu would need a rather different
approach.

Peter Jamieson

http://tips.pjmsn.me.uk

wrote:
Hi All

I'm a complete beginnier at mail merges so please be gentle.

I've inherited a mail merge were we want to have a formatted table
only if there is data present. The number of rows in the table
(excluding header) can be between 0 and 3, if its 0 then dont show the
table, otherwise only the rows with data.

Any help or pointers would be very much appreciated.

cheers

Keith

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] FuriousCanis@googlemail.com is offline
external usenet poster
 
Posts: 3
Default Conditional create table

Hi Guys

Thanks for the posts. It was a little more complicated, the data came
from a excel spreadsheet and was split horizontally rather than
vertically. In the end i went with using VBA to query the mergefields
to see if they contained a value, used that to work out the number of
rows needed, and then build the table programmatically. Theres
probably a better way, but that took less time to learn. Ah, the
whooshing sound of deadlines.

cheers

keith

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to conditional format in a Word table Under Pressure Tables 5 December 29th 07 07:36 PM
Conditional checkboxes within a table JANP Tables 1 May 4th 06 12:05 AM
create conditional data in label mail merge Corky Whiteboard Mailmerge 2 September 16th 05 06:02 AM
how do i create conditional text in Word docs mary dunn Microsoft Word Help 1 May 13th 05 08:01 PM
Possible to create conditional checkboxes in Word? Rosanne Ramos Microsoft Word Help 4 February 23rd 05 12:31 AM


All times are GMT +1. The time now is 06:55 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"