Home Subreports
New Blog Posts: Merging Reports - Part 1 and Part 2

How can I ask the subreport to print X times?

edited May 2003 in Subreports
Hi,

I have a main report with no data pipline, and there is a subreport in the
detail band,
1) How can I make the subreport to print X number of times?

2) Where should I put the code to update the count by one, and pass it to
the subreport so the subreport can re-excute the query with the new count.

Thanks

William

Comments

  • edited May 2003
    Where is the subreport? I'll assume you can't set the parent report's detail
    band to print more than once per record. This is what you'll have to do, so
    that te subreport is generated multiple times because its parent detail band
    is reprinting. There is another way. Where you have the subreport now, place
    a new subreport and drop the original subreport inside of it. Then set the
    new subreport's DetailBand.BandsPerRecord property to X. This way you can
    use this driver subreport that only has the real subreport in it to print X
    times.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Hi,

    What does exactly the BandsPerRecord property do? Does it just simply
    re-print the same record X times? the one I really want is that the most
    inner subreport should be re-execute the query to get the new records base
    on the new printing count. Could it be done?

    William

  • edited May 2003
    If you set BandsPerRecord, it will reprint the parent DetailBand X times,
    using the same record position. It won't refire the query.

    If the query is parameterized, you can use the DetailBand.BeforePrint event
    to set the new parameter on the detail query for the subreport. Then the
    detail will reprint and the subreport will reprint because its parent detail
    band is reprinting.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Hi, Jim

    How to make this kind of subreport to print start at a new page each
    time?

    William

  • edited May 2003
    Set the Subreport.PrintBehavior to pbSection. This will force it to take
    control of the page and it always starts on a new page with its own header
    and footer.

    The alternative is to use a group in the main report based on the key
    linking field and set the group to be StartOnNewPage.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Hi, Jim

    I just get confused, if I have the subreport1(it is in the detail band of
    main report), it has the subreport2 in the its detail band, in order to
    reprint subreport2 X times, which detailband.BandsPerRecord should be set to
    X times, according what you told me:


    1)I should set the subreport2's detail.BandsPerRecord set to X, but what if
    the subreport2's detail is in a group? Does the reprinting subreport2 X
    times still work?

    2) Which event in which subpreport should I use to put the following code:
    detail.BandsPerRecord := X;

    3) In which detailband.BeforePrint event, I should set a new parameter so
    the subreport2 can get the new query, I suppose it should
    Subreport1.detail.BeforePrint event, Right?


    William

  • edited May 2003
    Based on what you have said in prior posts, set
    Subreport1.DetailBand.BandsPerRecord = X. Use the Subreport1.BeforePrint
    event to set BandsPerRecord and to parameterize the query. The grouping
    should not matter, as the detail band is going to be reprinted. Only when
    the group break value changes, will the group break. The group should finish
    in the subreport and a group footer should appear. Then the detail is
    reprinted and the new subreport prints with a new group header and group
    footer for each group in the subreport2.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Hi, Jim

    Hmmm.... Where is the Subreport.BeforePrint event, I coundn't find such a
    event for the subreport, The only one I can see is that Subreport only has
    OnPrint event.

    William

  • edited May 2003
    Try the Detailband.BeforePrint event. The closest thing to BeforePrint for a
    subreport is the OnStartFirstPass event of the Subreport.Report object.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.