views:

723

answers:

1

Does anyone know how to set a height and width on a subreport so that it forces the subreport to wrap into several columns?

The delimma: I have to show a legend in a limited amount of space in a page header above a tabular report, and I'd like to limit the height of the legend so that it wraps into multiple columns, as needed. For example, the subreport might be pulling from a dataset containing 8 items: 1-red, 2-blue, 3-purple, 4-green, 5-yellow, 6-orange, 7-brown, 8-black. I'd like for the subreport to be formatted into 3 columns/3 rows, showing the first 3 in the first column, the next 3 in the 2nd column, and the last 2 in the last column.

Currently, the subreport is setup to have 3 columns, and the size of the subreport area inside of the master report is set to the exact same size as the subreport, itself. However, when I run either of the two, I'm getting only 1 column, and the height of the subreport is expanding to fit everything into 1 column.

Does anyone know of a work-around for this?

A: 

I would structure my query so that there are 4 columns, handling the logic for what colors are in your legend in SQL. That way you can guarantee that you always have at least 4 columns. If you have less than 4 just pass in null or empty values. Then the 4 column table for your subreport would be pretty straight forward.

The only other option I could think is to use a single text box and build your string with carriage returns after every 4th color...but that could be rather messy as well and you would have less control with the formatting (since you're using 2005).

HTH

PS. If you need some help structuring your query I'll be happy to help with that if post some code.

Mozy
Do you mean something like a cross-tab query? I like the idea, but I'm a little green to cross-tabs in SQL. Would you mind posting some sample code?
Kyle
It would depend on your data. Here is a good resource for using pivot (cross-tab query) in SQL 2005. http://www.mssqltips.com/tip.asp?tip=1019. It explains and shows it much better than I could. :)
Mozy
My first thought was to use case statements. Cross-tab may be a cleaner solution.
Mozy
great! Thanks for your help...
Kyle

related questions