[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Horizontal Spanning Subreports?

Posted on 2004-08-04
Medium Priority
Last Modified: 2008-02-01
Hello Experts,

I have been plotting for the best course of action for the next series of reports in a project and have gotten stuck.  I am trying to do something like this:

|Budget Categories|                        |Account1|                                             |Account2|                                                |AccountN|

                                |Budget| |Transactions| |Balance|              |Budget|  |Transactions| |Balance|                   |Budget|  |Transactions| |Balance|
Wages/Salary             $XX.xx       $XX.xx            $XX.xx                $XX.xx       $XX.xx            $XX.xx                     $XX.xx       $XX.xx            $XX.xx
Benefits                      $XX.xx       $XX.xx            $XX.xx                $XX.xx       $XX.xx            $XX.xx                     $XX.xx       $XX.xx            $XX.xx
etc.                            $XX.xx       $XX.xx            $XX.xx                $XX.xx       $XX.xx            $XX.xx                     $XX.xx       $XX.xx            $XX.xx

The number of accounts varies, anywhere from 1 to n.  The values are based on a primary key, so each Budget and Transaction can be retrieved using the same stored procedure.  I have read that the best (and it seems only) way to span horizontal pages is with crosstabs.  Can I feed some varying amount of subreports into a cross tab?  Any other ways of thinking that I'm missing?  Your input is greatly appreciated.
Question by:RuralInstitute
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 42

Expert Comment

ID: 11717618
>>> I have read that the best (and it seems only) way to span horizontal pages is with crosstabs.

This is correct.

>>> Can I feed some varying amount of subreports into a cross tab?


The way to do this I believe is to have the information for each account be a subreport.  Create a subreport that shows this information for a single account based on a parameter (account number?).  Have your main report pass the value to the subreport.  Size your subreport to be 1/3rd of the page width and place it in the details section of the main report.

In the main report use Report -> Section Expert -> Details -> Format for Multicolumn.  Then click the layout tab and enter the width as 1/3 of the page width.

This will give you a layout like this:


As long as you can pass some parameter from the main report to the subreport this will work.  I've tested with CR9 so it should work there or later.  I believe it'll work on older versions as well but I haven't tested.

This is over-simplified - it's going to take some tweaking to look right but hopefully this is enough info to get you on track.


Author Comment

ID: 11718011
So a single report with one paramter value (accountNumber) taking up one third of the page sounds like a good idea.

However the collection of paramterValues I give the report viewer will have multiple accountNumbers (a.k.a that which defines what data is returned).  Is Crystal smart enough to take each of the accountNumbers and apply them to the same subreport, especially since the parameter value name is only defined once?

Sorry this sounds so crazy, I'm having a hard time explaining it.  The hardest part about these reports is the accountants want them to look EXACTLY like the old ones.  Thanks for your help.
LVL 42

Accepted Solution

frodoman earned 2000 total points
ID: 11718096
Main report has one parameter which will contain multiple values, right?  These values are the list of account number(s) that should appear on the report?  If that's correct then that is exactly the scenario I was working with.

To test it, create a report that prompts for the parameter.  In your details section put only the account number field from your database.  Preview the report and enter three valid values for the parameter and you should see a report that looks something like this:

  D: account#1
  D: account#2
  D: account#3

Now insert another details section and create your subreport as described above and put it in details B.  Link {table.accountnumber} from main report into the parameter of your subreport - DON'T LINK THE MAIN REPORT PARAMETER TO THE PARAMETER OF THE SUBREPORT - that will get you a mess in this case.  This should give you this:

  Da: account#1
  Db: [subreport for account#1]
  Da: account#2
  Db: [subreport for account#2]
  Da: account#3
  Db: [subreport for account#3]

Now do the multicolumn stuff and suppress detail A and you're 90% of the way there.

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.


Author Comment

ID: 11944307
I have been on Crystal haitus for the last couple weeks.  I am now getting back into this - and again my brain is freezing.  I'm trying to figure out the best way to pass all the accounts in.  I get the accounts using a stored procedure, and right now they are sitting in a datatable.  My thought is to add multiple discrete values to a given parameter - is this the best way to go about it?  Here is what i'm thinking so far.

     ParameterFields paramFields = new ParameterFields();
     ParameterField paramField = new ParameterField();
     paramField.ParameterFieldName = "@bannerIndexCode";
          for(int i = 0; i < myTable.Rows.Count; i++)
                string currentDiscValue = "discreetValue" + i.ToString();

                //autoNames each discrete value so there is no overwriting - had problems with this before...
      ParameterDiscreteValue currentDiscValue = new ParameterDiscreteValue ;

                currentDiscValue.value = myTable.Rows[i].Value.ToString(); //Not sure of code here but you get the idea



My thought is by the time Crystal gets the parameterField Collection it will have the multiple account codes.  Sorry for making you work backwards like this but it always seems easier in my mind than it is to actually apply it.
LVL 42

Expert Comment

ID: 11944333
You've lost me.  Why not simply link them one at a time as I indicated in my last posting?


Author Comment

ID: 11944835
Ok Frodoman, I don't know what I was thinking with that last post, sorry.  *Doh*  As you suggested I just call the stored procedure that takes a parameter (called unitname) and returns a series of account numbers.  When i put it in the details section it spit out 3 account codes (which is correct).  Now I'm working on linking them to the sub-reports.
LVL 42

Expert Comment

ID: 11944876
Sounds good - let me know if you run into problems.

Author Comment

ID: 11945563
That was great.  I dont know if I would have figured that out on my own.  Thanks a million.

I'm going to post another question about getting the multi-column formatting to stick, but I wanted to get you the points for the original question.

LVL 42

Expert Comment

ID: 11945586
Glad i could help - frodoman

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question