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

How to Force a Page Break ?

Status
Not open for further replies.

snehakevin

Technical User
Sep 14, 2003
33
SG
How do I force a page break when the printing of detail line exceeds a particular number?

Example: I want to print lines not exceeding 29 or if the group ends and starts a new group. For new group It goes to the new page automatically but for line printed i have to force the page break..... How to do this...

Please help...
 
This is out of the microsoft access help file.

Use Visual Basic to force a page break in a report if a condition is met

1 Open the report in Design view.
2 In the toolbox, click Page Break , then click in the report section where you want a conditional page break.
3 Open the report's PageHeader_Format event procedure.
4 In the event procedure, add an assignment statement that sets the Visible property of the page break control to No. For example, if the name of the control is CondPgBreak, add the following assignment statement:

Me![CondPgBreak].Visible = False

This hides the page break control when the report starts formatting each page, so the page doesn't break.

5 In the Format event procedure of the section where you placed the page break, add Visual Basic code that sets the Visible property to Yes when a condition is met. For example, suppose you want a page break to occur in the detail section of the report if the value of the Counter control is 29, so that the first 29 records will print on the first page (Counter - Add a control on the same line as the detail and set its control source to =1 and its running sum to overgroup or overall). Add the following code to the Detail_Format event procedure:

If Me![Counter] = 29 Then
Me![CondPgBreak].Visible = True
End If

When the condition is met, the page breaks. After the page is broken, the event procedure attached to the page header hides the page break control until the condition is met again.

Hope this helps

Jonathan
 
Just to add a little something to Racal's post, if you want to break the records at 29 for each group that exceeds that number of records your code will look like this.

If Me![Counter] Mod 29 = 0 Then
Me![CondPgBreak].Visible = True
Else
Me![CondPgBreak].Visible = False
End If

Also, you would set the Running Sum property for your [Counter] textbox to Over Group.

Paul
 
Thank you Jonathan and Paul for your valuable sugesstion...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top