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

Force page break in middle of detail section

Status
Not open for further replies.

Mahatmt

Programmer
Jan 28, 2003
28
US

I have a report that resembles an invoice. It can have multiple line items that can expand (grow) in size depending on the size of a Description field that is included in the line. The total of the line items print in the Footer section.

In some cases, all of the line items print on page 1 and then the Footer with the total prints on page 2. Is there a way to force a page break before all of the line items are printed so that the total is not shown on a page without any line items?

Thanks.
 
You could try something like this.

Put a textbox in the detail section of your report. Set it's control source to =1. Set it's Running Sum Property to OverAll. Set it's visible property to No. Add a pagebreak to your report at the bottom of the detail section. Then in the Format event put something like this.

If Me.TextboxName > = 5 Then
Me.PageBreakName.Visible = True
Else
Me.PageBreakName.Visible = False
End If

If you get 5 records in the page then it will force a pagebreak. You can adjust the number to something more appropriate once you see how it works.

Paul
 

Paul:


I put a txt box and page break as you suggested. I put the code in the Detail_Format section (is that the right event)?

I get an error 2427 (You entered an expression that hasnot value message). When I run the report, I am being prompted to enter a value for 1 (it thinks the Control Source 1 is an input parameter.

Any suggestions?

Thanks. Mike

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.ForceBreak >= 7 Then

Me.PageBreakname.Visible = True
Else
Me.PageBreakname.Visible = False
End If

End Sub


Put a textbox in the detail section of your report. Set it's control source to =1. Set it's Running Sum Property to OverAll. Set it's visible property to No. Add a pagebreak to your report at the bottom of the detail section. Then in the Format event put something like this.

If Me.TextboxName > = 5 Then
Me.PageBreakName.Visible = True
Else
Me.PageBreakName.Visible = False
End If
 
Make sure you have the equals sign in front of the 1
=1
should be what's in the control source for the textbox. Also, make sure you set the Running Sum property for the textbox ForceBreak.

Paul
 
Paul;

Thanks. The pages are breaking, but how do I reset the Running Sum on the text box to 1? Once I reach a total of 7, I get a page break after every line.

I tried to set it with the VB code, but perhaps I did not select the correct property?

Thanks.

Mike
 
Sorry Mike I was a bit sloppy there. The code should be
If TextboxName Mod 7 = 0 Then
Me.PageBreakName.Visible = True
Else
Me.PageBreakname.Visible = False
End If

This will give you 7 records on each page.

Paul
 

Paul:

That appears to be the solution!

Much Thanks. Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top