473,379 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

forcing a page break in a report using code?

Hello,

I'm looking for a way to force a pagebreak in code. I'm having a tough
time, the first page formats properly until the condition is met and then
forces a new page. The problem is, every page after that forces a new page
after a single record. I'm trying to force the page after 12 records. The
code is pretty simple. I have a footer called "BreakFooter" that i have
associated with the ID field, so each detail record is unique. For
simplicity's sake, I've replaced the variable with hard coded numbers;

If MoveCount >= 12 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

Most of the searches I get return information on how to force a page break
using Grouping and Sorting, but no code really.

Any help would be great.

Thanks!
May 12 '06 #1
4 21502
On Fri, 12 May 2006 03:18:55 GMT, Rico wrote:
Hello,

I'm looking for a way to force a pagebreak in code. I'm having a tough
time, the first page formats properly until the condition is met and then
forces a new page. The problem is, every page after that forces a new page
after a single record. I'm trying to force the page after 12 records. The
code is pretty simple. I have a footer called "BreakFooter" that i have
associated with the ID field, so each detail record is unique. For
simplicity's sake, I've replaced the variable with hard coded numbers;

If MoveCount >= 12 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

Most of the searches I get return information on how to force a page break
using Grouping and Sorting, but no code really.

Any help would be great.

Thanks!


That's what your code is telling it to do.

What is MoveCount? A Counter control in the Detail section?
Try:
If [MoveCount] Mod 12 = 0 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

I would have simply added a PageBreak control to the detail section.
Code the Detail Format event:
Me![PageBreakName].Visible = Me![MoveCount] Mod 12 = 0

It would force a page break after each 12 records.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 12 '06 #2
Hi Fred,

Sorry about that, the MoveCount is a variable that increments by 1 every
detail line and then resets back to 0 when the page header formats.

I tried doing the pagebreak visible thing, but still have the same result.

Here's all the report code so you can see everything that's going on;

Dim MoveCount As Integer
Dim LastMoveCount As Integer
Private Const intLineCnt As Integer = 12 'CalcLinesToMove()

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

End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.MoveLayout = True
Me![PageBreakName].Visible = (MoveCount Mod 12 = 0)

If MoveCount < intLineCnt Then
Me.NextRecord = False
' Me.MoveLayout = True
'Me.PrintSection = False
MoveCount = MoveCount + 1

Else

Me.NextRecord = True
' Detail.ForceNewPage = 2
' Me.MoveLayout = True
'Me.PrintSection = True
End If
Exit Sub

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
MoveCount = 0
PageBreakName.Visible = False
'Detail.ForceNewPage = 0
'Detail.ForceNewPage = 0
End Sub

Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As
Integer)
Me![PageBreakName].Visible = False '(MoveCount Mod 12 = 0)
End Sub
It's driving me nuts at this point, this shouldn't be that hard! ;)


"fredg" <fg******@example.invalid> wrote in message
news:tw****************************@40tude.net...
On Fri, 12 May 2006 03:18:55 GMT, Rico wrote:
Hello,

I'm looking for a way to force a pagebreak in code. I'm having a tough
time, the first page formats properly until the condition is met and then
forces a new page. The problem is, every page after that forces a new
page
after a single record. I'm trying to force the page after 12 records.
The
code is pretty simple. I have a footer called "BreakFooter" that i have
associated with the ID field, so each detail record is unique. For
simplicity's sake, I've replaced the variable with hard coded numbers;

If MoveCount >= 12 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

Most of the searches I get return information on how to force a page
break
using Grouping and Sorting, but no code really.

Any help would be great.

Thanks!


That's what your code is telling it to do.

What is MoveCount? A Counter control in the Detail section?
Try:
If [MoveCount] Mod 12 = 0 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

I would have simply added a PageBreak control to the detail section.
Code the Detail Format event:
Me![PageBreakName].Visible = Me![MoveCount] Mod 12 = 0

It would force a page break after each 12 records.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

May 12 '06 #3
Report Section Events are pretty arcane.
Have you tested to ensure that this line
MoveCount = 0
is actually executed each time you think that it is executed?
Have you considered removing that line and using
MoveCount Mod IntLineCount = IntLineCount - 1 as your test statement?

May 12 '06 #4
On Fri, 12 May 2006 04:13:41 GMT, Rico wrote:
Hi Fred,

Sorry about that, the MoveCount is a variable that increments by 1 every
detail line and then resets back to 0 when the page header formats.

I tried doing the pagebreak visible thing, but still have the same result.

Here's all the report code so you can see everything that's going on;

Dim MoveCount As Integer
Dim LastMoveCount As Integer
Private Const intLineCnt As Integer = 12 'CalcLinesToMove()

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

End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.MoveLayout = True
Me![PageBreakName].Visible = (MoveCount Mod 12 = 0)

If MoveCount < intLineCnt Then
Me.NextRecord = False
' Me.MoveLayout = True
'Me.PrintSection = False
MoveCount = MoveCount + 1

Else

Me.NextRecord = True
' Detail.ForceNewPage = 2
' Me.MoveLayout = True
'Me.PrintSection = True
End If
Exit Sub

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
MoveCount = 0
PageBreakName.Visible = False
'Detail.ForceNewPage = 0
'Detail.ForceNewPage = 0
End Sub

Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As
Integer)
Me![PageBreakName].Visible = False '(MoveCount Mod 12 = 0)
End Sub

It's driving me nuts at this point, this shouldn't be that hard! ;)

"fredg" <fg******@example.invalid> wrote in message
news:tw****************************@40tude.net...
On Fri, 12 May 2006 03:18:55 GMT, Rico wrote:
Hello,

I'm looking for a way to force a pagebreak in code. I'm having a tough
time, the first page formats properly until the condition is met and then
forces a new page. The problem is, every page after that forces a new
page
after a single record. I'm trying to force the page after 12 records.
The
code is pretty simple. I have a footer called "BreakFooter" that i have
associated with the ID field, so each detail record is unique. For
simplicity's sake, I've replaced the variable with hard coded numbers;

If MoveCount >= 12 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

Most of the searches I get return information on how to force a page
break
using Grouping and Sorting, but no code really.

Any help would be great.

Thanks!


That's what your code is telling it to do.

What is MoveCount? A Counter control in the Detail section?
Try:
If [MoveCount] Mod 12 = 0 Then
BreakFooter.ForceNewPage = 2
Else
BreakFooter.ForceNewPage = 0
End If

I would have simply added a PageBreak control to the detail section.
Code the Detail Format event:
Me![PageBreakName].Visible = Me![MoveCount] Mod 12 = 0

It would force a page break after each 12 records.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


That's what I suspected. It's not a control. You're attempting to
count in the Format event.
The Format event can fire more than once as Access attempts to format
the page.

Do it differently.
No need for a special Group to force the page to break.

Add an unbound control to the Detail Section.
Set it's Control source to
=1
Set it's Running Sum property to
Over All (or Over Group, which ever is appropriate).
Name this control "RecCount".
You can make it not visible.

Add the PageBreak to the Detail Section.
Name the Page Break "MyBreak".
Code the Detail Format event:

[MyBreak].Visible = RecCount Mod 12 = 0
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chuck | last post by:
A report has many different groups of multiple pages each. Each group starts on a new page. The report is printed on both sides of the paper. I would like to be able to have each group start on...
2
by: Marco | last post by:
I need to force the new page in a particular point of a report according the value of a variable or an expression (if varX=true then force the new page). Thanks in advance for tips.
1
by: kaosyeti | last post by:
hey... i have a report that groups on salespeople. the report footer is a three part summary of the store's total data with 2 different departments for parts 1 and 2 and a store total for part 3. ...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
1
by: David | last post by:
Folks, I have four subreports in a report in the detail section. I suppose I could move them to the footer of the report. Anyway, if any of them have data, I want the main report to force a...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
4
by: mikeDA | last post by:
I have an invoice report in Access. I have three invoices. I want to force a page break after each invoice# so I end up with three invoices, each with a header (invoice# date etc.), detail (items...
1
by: Simon | last post by:
Dear reader, Is there some VBA code to place or remove a page break on the bottom of the report header section? In some cases only the header section of the report has to be printed in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.