• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

Create a page 2 of a report if sub report query count >3

Good day.

I have a report built of sub-reports.  There is a sub report that will list items from a query.  
If the count of records in the query is more than three then I want a page two created with records 4-6 and so on.

So, If I have 11 items I should end up with four copies of the report.. each with three entries and the last with 2.

so, my question is this.  What is an easy and clean method of implementing this?

thank you for your time.
K
0
chad
Asked:
chad
  • 4
  • 4
1 Solution
 
harfangCommented:
Hello,

The following module will force a page break after each third detail section:

-----------------------------------------------------------------------------------------------
Option Explicit

Dim gintCounter As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    gintCounter = gintCounter + 1
    Me.Detail.ForceNewPage = IIf(gintCounter Mod 3 = 0, 2, 0)
End Sub
-----------------------------------------------------------------------------------------------

You can use this on a subform.

Hope this helps,
(°v°)
0
 
chadAuthor Commented:
thanks for the quick reply.  I will have to test it out tomorrow.  
0
 
chadAuthor Commented:
okay.  It works.. sorta.
I have the vba in the event procedure for the details section of the subreport.

When I do that it causes a page break in the entire main report.
i.e. it does not include the remaining data.  

Is there a way to make the main report do a page break based on the three item count?
thanks,
K
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
harfangCommented:
Hello,

Well, does it need to be a subreport? Can't you use the main report to do that? E.g.

+----------------------
 | page header
 | to fill the top
 | portion of the
 | page
+----------------------
 | 1. Aaa aaa
 | 2. Bbb bbb
 | 3. Ccc ccc
+----------------------
 | page footer
 | for the rest
+----------------------

This method create a page break in the subreport. That page break is propagated to the main report. After that, the main report will only print the page footer, nothing else, quite naturally.

You seem to expect something else. Can you be more precise? What sort of "page break" are you imagining for the main report?

You might want to look at a similar thread: http:/Q_21834220.html

Cheers!
(°v°)
0
 
chadAuthor Commented:
thanks,

I came to the same conclusion...sorta.  I only have the subreport in the detail section.  every thing else is in a footer/header.
Now I want to ensure that each page has three... no more no less.

this is the general idea

itemlist  1) item 1                name  1) blah
            2) item 2                          2) blah again  
            3)  itme 3                         3) blah blah

I have all of this on a subreport but when I have only one item, I only get one line.  I still want three lines to show up and have the last two blank.
I could use TOP 3 as you suggested in the other thread but I think that will give me the same results I have now.

thanks.
K
0
 
harfangCommented:
It would.

If you use the page footer for the remaining information, it's aligned to the bottom marging, so that you would end up with blank space where the two additional lines could have been.

If you need to actually print something there, it's a little more comples, and requires VB again.

I created a small demo module for a report that fills each page with 40 lines. Change the constant and you can use that to print three lines: http:/Q_21617721.html

See if that works, or we can adapt it for you.

Good luck!
(°v°)
0
 
chadAuthor Commented:
Thanks, I will play and hopefuly learn tomorrow
0
 
harfangCommented:
Tell me how it goes. It might take some tweaking.
(°v°)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now