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