I have a calculated field: TotalDiff. It is the sum of amounts in repeating subforms. I want this calculated amount to display in red if it is a negative amount. I have used FormCalc as this was the only way I could figure out how to sum the amounts from the repeating subforms. I have never used FormCalc before and cannot figure out how to do the font colour change. From reading other discussion threads, I thought the following should work, but it doesn't. The sum formula works fine by itself, but when I add the if/else for the font colour, even that stops working. Where am I going wrong?
form1.TotalBlock.TotalDiff::calculate - (FormCalc, client)
TotalDiff = Sum(ItemBlock[*].Diff)
if (form1.TotalBlock.TotalDiff.rawValue<0) then form1.TotalBlock.TotalDiff.font.fill.color.value="255,0,0"
Ok, I'm suggesting to not use the Action Builder as it creates clunky scriptings with a lot of limitations.
To change the fields color you can use the following script (FormCalc).
$ = Sum(ItemBlock[*].Diff)
if ($ lt 0) then
Thanks Josh, I did try using the action builder first because I'm really bad with code, but I only lets me do it as an exit script so it doesn't actually do the colour change unless the user tabs through or clicks in and out of that total field (which they wouldn't usually do 'coz it's a calculated field). Do you know of a way to get it do this as a calculate or validate action?
Thanks radzmar, but I just can't get it to work
It is doing the same as the original script I had - calculation formula works fine but once the colour script goes in even the formula stops working. I tried moving the colour script portion to validate event but that doesn't work either. Would it make a difference that I'm not using tables, just fields?