Changing BGColor of Browse Calc field

Jenie888

Member
I want to change the BGColor of a field in a browser.

I use :

TableName.FieldName:BGCOLOR in Browser br-Table = 15.

This works on normal fields from a table, however some of my fields displaying in my browser are CALCULATED fields.

Does anyone have any suggestions on how I can change the BGCOLOR of a Calculated field in a browser?

Thanks,
Jenifer
 

dkellgren

Member
You can "walk" the columns in the browser, and once you reach the desired one, change its BGCOLOR. This may not be the most efficient, but it works...

DEFINE VARIABLE FirstColumn AS HANDLE NO-UNDO.
DEFINE VARIABLE NextColumn AS HANDLE NO-UNDO.

FirstColumn = br-Table:FIRST-COLUMN.
NextColumn = FirstColumn:NEXT-COLUMN.
NextColumn = NextColumn:NEXT-COLUMN.
NextColumn = NextColumn:NEXT-COLUMN.
NextColumn:BGCOLOR = 15.

Give it try...

-dk-
 

M-HT

Member
More simple solution is to define the calculated field like this:
field1 + field2 @ Variable
Then you can set the bgcolor like this:
Variable:BGCOLOR IN BROWSE br-Table = 15.
 

Jenie888

Member
Thanks DK for the suggestion, however this code needs to be done on the record level, therefore I am running it int the row-display trigger. Your code generates an error because the handle of a collumn is not queryable at the row-display level.

M-HT thanks for the suggestion I will check it out.

Thanks,
Jenifer
 

Jenie888

Member
M-HT

I am a little confused on your suggestion. How exactly would one state

Field 1 + Field 2 @ Variable?


Thanks,
Jenie
 

dkellgren

Member
Sorry to have caused you errors. Perhaps next time, you could provide more detail so we don't have to guess at your intentions.

-dk-
 

Jenie888

Member
Guess work is not necessary. Your idea was good, just not what I needed. While I appologize for not specifically stating I was writing the code in the row-display trigger, it was not my intention to neglect to give out information. I wasn't aware at the time that it would matter, however for your erroneous code it did.

:D
 

jongpau

Member
Hi Jenifer,

Not sure whether you fixed your problem yet, but I will give it a go anyway.

The way I have done this before is:
1. Define a variable that can hold the value of your calculation.
2. Display the variable instead of the calculation in the browse.
3. In the Row-Display trigger assign the variable with the result of your calculation.
4. Set the colors you want of the calculated field with FieldName:BGCOLOR IN BROWSE YourBrowse = Color etc.

That should do the trick :)

HTH.
 

m1_ru

New Member
> I am a little confused on your suggestion. How exactly would one state
> Field 1 + Field 2 @ Variable?

Try next:
1. Go to Definitions section of your browser
<code>
define variable v-calc-field as character no-undo format "x(20)" label "Calc field" .
</code>

2. Go to Column editor. Press 'Edit...' on calculated field.
Use the variable to display calculated field.
<code>
field1 + ' ' + field2 <b>@ v-calc-field</b>
</code>
Check syntax.

3. Now you can use v-calc-field like any other field to specify background color .
 

walkeryan

Member
The solution is simple really, just get your favorite highlighters, and if you don't mind getting your screen a little messy, go from there 8*)
 
Top