473,804 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "BreakFoote r" 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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 21581
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 "BreakFoote r" 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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 'CalcLinesToMov e()

Private Sub BreakFooter_For mat(Cancel As Integer, FormatCount As Integer)

End Sub

Private Sub Detail_Format(C ancel 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.PrintSectio n = False
MoveCount = MoveCount + 1

Else

Me.NextRecord = True
' Detail.ForceNew Page = 2
' Me.MoveLayout = True
'Me.PrintSectio n = True
End If
Exit Sub

End Sub

Private Sub PageHeaderSecti on_Format(Cance l As Integer, FormatCount As
Integer)
MoveCount = 0
PageBreakName.V isible = False
'Detail.ForceNe wPage = 0
'Detail.ForceNe wPage = 0
End Sub

Private Sub PageHeaderSecti on_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******@examp le.invalid> wrote in message
news:tw******** *************** *****@40tude.ne t...
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 "BreakFoote r" 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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 'CalcLinesToMov e()

Private Sub BreakFooter_For mat(Cancel As Integer, FormatCount As Integer)

End Sub

Private Sub Detail_Format(C ancel 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.PrintSectio n = False
MoveCount = MoveCount + 1

Else

Me.NextRecord = True
' Detail.ForceNew Page = 2
' Me.MoveLayout = True
'Me.PrintSectio n = True
End If
Exit Sub

End Sub

Private Sub PageHeaderSecti on_Format(Cance l As Integer, FormatCount As
Integer)
MoveCount = 0
PageBreakName.V isible = False
'Detail.ForceNe wPage = 0
'Detail.ForceNe wPage = 0
End Sub

Private Sub PageHeaderSecti on_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******@examp le.invalid> wrote in message
news:tw******** *************** *****@40tude.ne t...
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 "BreakFoote r" 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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.For ceNewPage = 2
Else
BreakFooter.For ceNewPage = 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
4548
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 a right hand page, that is, to be printed on an odd numbered page. something like iif(page mod0 is true then force to next page). All suggestions will be gratefully received. Chuck ....
2
1548
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
2564
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. part of the form that creates the report is the ability to select a specific department. it is when that happens, that i need 2 of the 3 parts of the report footer to be visible=false. now i've got that working but here's the real problem. ...
1
8188
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 the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I have written to send a test message: -----Code Begins: Sensitive Information Replaced by -----...
1
3592
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 page break. I am trying to use the "hasdata" property for the subreports, but I am getting the generic error indicating property not available for object. How does one tell the main report (using VBA) not to throw in a page break unless the...
14
23176
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, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
4
4762
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 purchased, cost, extension etc) and a footer (totals, amount due etc.). I can't for the life of me do this after spending a morning trying to use the force page break proprty setting. My invoice design has a report header (invoice# etc.), page header...
1
3111
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 that situation no page break is required and in other cases I need a page break on the bottom of the report header section.
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5676
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.