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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Multiple Records on Same Line in Separate Columns

Status
Not open for further replies.

fuzzyocelot

Programmer
Jul 22, 2003
333
US
Hi, everyone!

I’ve searched through the forum and haven’t found anything similar to my problem. If I missed a posting, I apologize and ask that someone direct me to it.

Otherwise, my problem is as follows:
(Note: using Crystal 9 and database is Oracle 9i)

How the “Country” table is structured:
[tt]
Country Country
[/tt][tt]Code Name ID Desc[/tt][tt]
AO Angola 1 Kwanza
AO Angola 1 New Kwanza
AO Angola 3 Banda
AO Angola 3 Portuguese
[/tt]
The “ID” field translates to:
1 = Currency
3 = Language

Here’s how it needs to be displayed on the report:
[tt]
Country Country [/tt]
[tt]Code Name Currency Language[/tt][tt]
AO Angola Kwanza Banda
New Kwanza Portuguese
[/tt]
What I’ve done so far is to put the Country Code and Name fields in a group header. Then I created 2 formulas and put them in the details section:

Code:
@DisplayCurrency:
if {ID} = 1 then {Desc};

@DisplayLanguage:
if {ID} = 3 then {Desc};

But now the report looks like this:
[tt]Country Country[/tt]
[tt]Code Name Currency Language[/tt][tt]
AO Angola Kwanza
New Kwanza
Banda
Portuguese
[/tt]
How do I get the Currency and Language fields to display in separate columns right next to each other?

I appreciate any advice you may have.

Thanks,
Rebecca
 
I would solve it as follows (this code has not been tested but will be very close):

1. Group on Country Code as you have done
2. Create a formula to build the list of currencies and languages as follows:

Code:
@BuildTexts
WhilePrintingRecords;  
StringVar MyCurrency;
StringVar MyLanguage;

if {ID} = 1 then 
   // Add to Currency
   if len(MyCurrency) = 0 then 
      // 1st time
      MyCurrency := {Desc}
   else
      // Not the 1st time
      MyCurrency := MyCurrency + chr(13) + {Desc}
else
   // Add to Language
   if len(MyLanguage) = 0 then 
      // 1st time
      MyLanguage := {Desc}
   else
      // Not the 1st time
      MyLanguage := MyLanguage + chr(13) + {Desc}

@ShowMyCurrency
WhilePrintingRecords;  
StringVar MyCurrency;

@ShowMyLanguage
WhilePrintingRecords;  
StringVar MyLanguage;

@ResetTexts      
WhilePrintingRecords;  
StringVar MyCurrency:="";
StringVar MyLanguage:="";

Then place the ResetTexts forumla in the group header, the 2 show formulas in the group footer and the BuildTexts formula in the details section.

Also make sure you place the country code and country description in the footer section too. And make sure the show formulas are formatted with 'can grow'.




Steve Phillips, Crystal Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top