Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shading within a concatenated text field

Status
Not open for further replies.

RoknRole

Programmer
Feb 2, 2005
36
0
0
US
Here's a puzzle for Tek-Tips!

Using Crystal Reports 2008, with data that looks something like this:

Abbrev Name Property_1 Property_2 Property_Etc
BTL Long name for BTL 4 5 7
CDV Long name for CDV 7 6 8
EFB Long name for EFB 7 2 3

In the Details section of the report, there is room to display the Abreviation and all the numerous Property field columns. There is insufficient room to display the Name. For improved readability, every other row in the Details section is shaded a light gray using the following formula in the Section Expert > Details > Color area:

Code:
if remainder(recordnumber,2) = 0 then color(240,240,240) else crnocolor

The Abreviation and Name are displayed in the Report Footer using a series of 3 formulas (a technique I learned several years ago thanks to Tek-Tips!):

Code:
//{@Clear_ListNames}
//Placed in the Report Header
//Clears the variable
whileprintingrecords;
global stringvar ListNames;
ListNames:= "";

Code:
//{@Form_ListNames}
//Placed in the Details section
//Forms or concatenates the Abbreviation and Name fields,
//and adds a carriage return between each series.
whileprintingrecords;
global stringvar ListNames;
ListNames:= ListNames & {ABBREV_FIELD} & " - " & {NAME_FIELD} & chr(13);

Code:
//{@Display_ListNames}
//Placed in the Report Footer
//Displays the concatenated field
whileprintingrecords;
global stringvar ListNames;
ListNames;

The {@Display_ListNames} formula is formated so that it can grow. When the report is run, the Details appear in the main body of the report (with every other row shaded) and the Abbreviations and Names successfully appear at the end of the report on separate lines or "rows" for each Abbreviation and Name - kind of like a footnote at the end of the report explaining what the abbreviations mean.

So far so good. Now, is it possible to shade every other "row" in the concatenated text field in the Report Footer in a fashion similar in appearance to shading every other row in the Details section?



 
I don't think there is a way to embed a color background in a formula, but you could change the font color on every other line.

Another possibility would be to create a series of text boxes in a RH_a section where every other one is light gray and then format the RH_a section to underlay RH_b where your display formula is. You would have to conditionally suppress the text boxes based on the total record count, so that you could get a match.

Let me know if you want to try the font color change.

-LB
 
Thanks lbass for your response! And I apologize for not including what I had already tried.

I can't think of a way either to embed a color background in a formula.

I thought about a font color change, and have done that in other reports using HTML code embedded in the concatenated text. But in this particular report, the shading of every other row (in a fashion similar to the Detail rows) is the desired output.

I've also tried another series of 3 formulas which concatenate a webdings font. The "Form" formula of that series is similar to the following:

Code:
//{@Form_Shade}
//Placed in the Details section
//When the Webdings font is used, the chr(103) character is a near solid block 
whileprintingrecords;
global stringvar Shade;
numbervar rowct; 
rowct:= rowct + 1;
if remainder(rowct,2) = 0 then Shade:= Shade & replicatestring(chr(103), 48) & chr(13)
else Shade:= Shade & chr(13);

The {@Form_Shade} formula is placed in RFa, and is formated to grow, and use a light gray Webdings font. The RFa section is configured to underlay RFb where the original {@Display_ListNames} formula is located. The result is close to the entire row being shaded, but it appears as a series of unconnected boxes.

Can you expand a little more on your other possibility? How would you conditionally suppress a Report Footer subsection based on the number of "rows"?
 
You should be able to use formulas like this:

count({table.anyrecurringfield}) < 10 //for the 10th box

Whether this approach is realistic depends upon the maximum number of possible values.

While you can use html tags for font color in CR, CR does not currently support background color, AFAIK.

-LB
 
Thanks lbass. At your suggestion, I tried the shaded text boxes with the provided suppression formula in a separate section, and it worked. Thanks! However, as you hinted, that approach is not entirely realistic in this situation because the number of rows can greatly vary. In instances where only a couple of rows are needed, the report still needs to allot the space needed for the "unused" and thus suppressed text boxes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top