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

CR 8.5 - dynamic columns | howto

Status
Not open for further replies.

nyseguy

Programmer
Jan 18, 2005
5
US

Hello. I am trying to create a report where the number of columns can vary (ie. could be 3 or 5, etc.) How can this be done?

I am already working on one approach where I created a table with maximum possible columns, and I managed to suppress the columns that contain NULLs on the report. This solves the issue of hiding empty columns, but crystal does not adjust the space used by suppressed columns - I have blank columns now in the report. Can I shift columns with data to replace those that were suppressed using crystal?

Ideas on different approaches or help with the one I am working on are really appreaciated.

Thanks.
 
A bit vague, how would the report know when it is to use 3 or 5 or ? number of columns?

Is it based on a parameter? The state of the data (all nulls in some column), or???

A standard approach is to have omething to key off of, such as a parameter or a condition:

Column 1 might contain:

If {?MyParm} = 3 then
{table.field1}
else
{table.field2}

You get the idea, except that if you have different data types, you'll have to convert them to a standard data type or use multiple formulas in the same space and conditionally suppress based on whatever condition.

-k
 
>>A bit vague, how would the report know when it is to use 3 or 5 or ? number of columns?

That is part of my question...only in my stored proc I can determine how many columns report should contain.

Simple example would be Company A has 3 employees, Company B has 5 employes. If user selects to run report for Company A, 3 columns will be displayed; if for Company B, 5 columns will be displayed.

The columns that I am currently supressing contain NULLs for all rows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top