Problem forced page-break in report after fixed number of header-sections (1 Viewer)

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
In Access97 I want to create a report with this structure (report-sections):

-Header-Text 0
--Header-Text 1: this section has a 'tally' (Textbox with running total to give each section a unique numer)
---Detail

--------
Example report (Now):

*pag.1:
-H.0
--H.1-1: A
---Det.1-1-1
---Det.1-1-2
---Det.1-1-3

--H.1-2: A
---Det.1-2-1
---Det.1-2-2

--H.2-1: B
---Det.2-1-1
---Det.2-1-2

*pag.2:
--H.2-2: B
---Det.2-2-1
---Det.2-2-2
--------

But what I want is that on every page always appear 2 sections of Header-Text 1, so the above example should be this:

--------
Example report (Required):

*pag.1:
-H.0
--H.1-1: A
---Det.1-1-1
---Det.1-1-2
---Det.1-1-3

--H.1-2: A
---Det.1-2-1
---Det.1-2-2

*pag.2:

--H.2-1: B
---Det.2-1-1
---Det.2-1-2

--H.2-2: B
---Det.2-2-1
---Det.2-2-2
--------

I thought I could do this with the tally/counter in section Header-Text 1, with this code:

--------

Private Sub HeaderTxt1_Format(Cancel As Integer, FormatCount As Integer)
Dim i As Integer

i = CInt(Me.txt_Tally.Value)

If (i Mod 2) = 0 Then
Me.HeaderTxt1.ForceNewPage = 2
Else
Me.HeaderTxt1.ForceNewPage = 0
End If

End Sub

--------

But this doesn't work well, the page-breaks are not put on the places I want, I have e.g. a page with only header-text and the detail-text on another page (in stead of having them together, on the same page). I also tried to move the code above to the Format-event of the Detail-section, but this also doesn't work well. Could anyone please tell me what I'm doing wrong? .
 

stopher

AWF VIP
Local time
Today, 23:11
Joined
Feb 1, 2006
Messages
2,395
The event trigger is fine. Just set the forceNewPage of the corresponding footer not the header.

hth
Chris
 

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
I have added the footer(-1) corresponder to section header-1, placed the tally/counter in the footer, and also a page-break-control, and the Format-event of the footer-1 is:

--
i = CInt(Me. txt_Tally.Value)

If (i Mod 2) = 0 Then
Me![CondPgBreak].Visible = True
Else
Me![CondPgBreak].Visible = False
End If
--

And the result is I have one group per page:

Example report:

*pag.1:
-H.0
--H.1-1: A
---Det.1-1-1
---Det.1-1-2
---Tally: 1

*pag.2:
--H.1-2: A
---Det.1-2-1
---Det.1-2-2
---Tally: -

*pag.3:
---Tally: 2 (of pag.2)
--H.2-1: B
---Det.2-1-1
---Det.2-1-2
---Tally: 3 (of pag.3)

*pag.4:
--H.2-2: B
---Det.2-2-1
---Det.2-2-2
---Tally: -

*pag.5:
---Tally: 4 (of pag.4)
 

stopher

AWF VIP
Local time
Today, 23:11
Joined
Feb 1, 2006
Messages
2,395
I have added the footer(-1) corresponder to section header-1, placed the tally/counter in the footer, and also a page-break-control, and the Format-event of the footer-1 is:

--
i = CInt(Me. txt_Tally.Value)

If (i Mod 2) = 0 Then
Me![CondPgBreak].Visible = True
Else
Me![CondPgBreak].Visible = False
End If
--

And the result is I have one group per page:

Example report:

*pag.1:
-H.0
--H.1-1: A
---Det.1-1-1
---Det.1-1-2
---Tally: 1

*pag.2:
--H.1-2: A
---Det.1-2-1
---Det.1-2-2
---Tally: -

*pag.3:
---Tally: 2 (of pag.2)
--H.2-1: B
---Det.2-1-1
---Det.2-1-2
---Tally: 3 (of pag.3)

*pag.4:
--H.2-2: B
---Det.2-2-1
---Det.2-2-2
---Tally: -

*pag.5:
---Tally: 4 (of pag.4)
Not sure what you are saying here. Are you saying you've resolved your problem? This doesn't look like what you wanted to achieve.
 

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
Not sure what you are saying here. Are you saying you've resolved your problem? This doesn't look like what you wanted to achieve.

No, it's not solved, but at least the formatting is now better: group(header) + detail stay together on 1 page, but only 1 group per page, while I want a fixed number (2) of groups/header-1 per page.
 

stopher

AWF VIP
Local time
Today, 23:11
Joined
Feb 1, 2006
Messages
2,395
Did you try the solution I suggested? You were almost there with your first post. just change the two ForceNewPage lines to refer to the footer.

Chris
 

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
Did you try the solution I suggested? You were almost there with your first post. just change the two ForceNewPage lines to refer to the footer.

Chris

Yes, i did try that, but it didn't work, headers, details and footers were not kept on 1 page, but e.g. header-1 on pag.1, detail-1 on pag.2 etc., a mess.
 

stopher

AWF VIP
Local time
Today, 23:11
Joined
Feb 1, 2006
Messages
2,395
Can you post your database. I can post an example but I can only post as Access 2000.
 

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
If you could post your DB, I'll have another PC with Ac.2000, my mDB is quit big. Thank you in advance.
 

stopher

AWF VIP
Local time
Today, 23:11
Joined
Feb 1, 2006
Messages
2,395
here you go. Make sure you run the report in Print Preview to see the effect
 

Attachments

  • pageBreak.zip
    14 KB · Views: 155

mvanreek

Registered User.
Local time
Today, 23:11
Joined
Jan 22, 2011
Messages
13
here you go. Make sure you run the report in Print Preview to see the effect

Ok , now it works (I forgot to change the code that was putting the page-break on the header, in stead of the footer). Sometimes after too much hours behind the monitor, you dont see things so clear anymore..
Thank you very much for your help.
 

Users who are viewing this thread

Top Bottom