cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the background colour of a field where the colour is specified within a field

0 Kudos

Hello,

I am looking to set the background of my fields where I have the colour specified within my query.

For example I have my answer field and a colour has been associated with this field by the user called 'AnswerColour' where within that it will HEX colour code e.g. #3be711.

I need the query to use the colour within this field and set it as the background.

former_member751591
Participant
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend you to read this overview Community Q&A, and to take our Q&A tutorial . With these tips you'll be able to prepare questions that draw responses from our members.

The more details you provide, the more likely it is that members will be able to answer your question.

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a Picture to your profile you encourage readers to respond.

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

Unfortunately, Crystal doesn't seem to be able to take colors in this format. It can however, take them in RGB format using a formula like this:

if not IsNull({MyTable.AnswerColour}) then color(R, G, B) else crNoColor

Another possible way to do this would be to determine what each possible color is and, if it's one of the colors defined by Crystal's color constants, replace it by the constant. You can search for "Color Constants" in the Crystal Help to see what they are.

-Dell

0 Kudos

Hi Dell,

Thank you for your reply. If it was in the RGB format would I be able to take the data from the field and use it instead of specifying a particular colour within the code?

Thanks,

Daneka

DellSC
Active Contributor
0 Kudos

Yes, you would be able to do that.

-Dell

Answers (2)

Answers (2)

ido_millet
Active Contributor
0 Kudos

You can convert hex to rgb using Crystal formula logic as shown below.
This type of conversion is made easier by using a UFL that converts hex to numeric values.

See list of 3rd-party UFLs here.

ido_millet
Active Contributor
0 Kudos

Right-click the field in Crystal Reports Designer,
Select 'Format Field...',
Select 'Border' tab.
Enter a dynamic expression for the 'Background' property.