Conditional formatting question

P

Paja

Hello all,

I 'd like to use the conditional formating do display diferent background
color for for even and odd rows in repeating table. Can you help me, how to
do it ?

Thanks for any help,

p.
 
S

Scott L. Heim [MSFT]

Hi,

In order to implement alternating line colors, you need to have the
following:

- A field that gets the count of the rows in the repeating table and uses
the "MOD" function (call this fldCount)
- A new column in your table that uses the "current()" function and
references the result of the above (call this fldMODRef)
- Conditional formatting on the repeating table that looks to the field:
fldMODRef to see if this is a 1 or a 0 and then apply the shading

Here are some basic steps that you will need to "tweak" in your scenario:

- Add a new text box to your form (not the repeating table) named: fldCount
set the Default Value to an expression similar to the following:

count(../my:group1/my:group2/my:field1) mod 2

** NOTE: I simply used the Insert Formula button to use the "count"
function and then drill down to one of the fields in my repeating table.
Once I selected the field, I used the "Edit XPath" options to add the "mod"
function

- Add a new column to your repeating table
- Set the Default Value of the text box in this new column to:

current()/../../../my:fldCount

** NOTE: In this case, I used the Insert Field button to select fldCount
and then chose the Edit XPath option to add the "current()" function

- Add Conditional Formatting to the table that is similar to:

- First drop-down box: the new field in your repeating table
- Second drop-down box: is greater than or equal to
- Third drop-down box: 1

- Set the format of each of the new text boxes to be Decimal (Double)

Here is how this works:

- The field: fldCount gets a count of all the rows in the repeating table
and then the "mod" function is applied. What this does is take the count,
divide it by the number you enter (in our case, 2) and return the
remainder. (Even number of rows would return 0 - odd numbers return 1)
- The new field in your repeating table simply references this field with
the "current()" function is used to keep the reference unique for each row
- The conditional formatting simply looks to this new field in the table
and if the value is 1 or more, shades the row!

I hope this helps!!

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Scott L. Heim [MSFT]

Hi,

Greg's suggestion is much better - thanks Greg!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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