Reset the pages count for each section

G

Guest

I learned how to reset the page value (using a macro) for each new section on
my report. I now also need to reset the pages count. I have a lot of data
that I need to be formatted a certain way, and I basically want to see page 1
of 2 then page 2 of 2 then page 1 of 3 for the next section and so on. I can
reset the page, but not the pages.
 
F

fredg

I learned how to reset the page value (using a macro) for each new section on
my report. I now also need to reset the pages count. I have a lot of data
that I need to be formatted a certain way, and I basically want to see page 1
of 2 then page 2 of 2 then page 1 of 3 for the next section and so on. I can
reset the page, but not the pages.

See:

Printing First and Last Page Numbers for Report Groups
http://www.mvps.org/access/reports/rpt0013.htm
 
G

Guest

I have added this code to the report, and it still does not keep track of the
pages for the section. The note says

Note: the line Me!Salesperson should be changed to the control name of the
group you wish to track pages for. Me!ctlGrpPages is the name of a control
you should place in the page footer. You can also change this line to
whatever form you wish your page numbers to take.

I think that this is what I am missing, but I do not know where to paste the
ME!ctrlGrpPages?

Thanks
 
F

fredg

I have added this code to the report, and it still does not keep track of the
pages for the section. The note says

Note: the line Me!Salesperson should be changed to the control name of the
group you wish to track pages for. Me!ctlGrpPages is the name of a control
you should place in the page footer. You can also change this line to
whatever form you wish your page numbers to take.

I think that this is what I am missing, but I do not know where to paste the
ME!ctrlGrpPages?

Thanks

1)
You need to have a control on the report that computes [Pages].
You can use
= [Pages]
and make this control not visible.

2)
No one has any idea what Field your actual report is grouped on.
You need to change (in the code)
GrpNameCurrent = Me!Salesperson
to
GrpNameCurrent = Me!YourControlName

Where YourControlName is the name of the control that the report is
grouped on.

3)
Where do you wish to show the "Page 1 of 3" on the report.
Probably in the Page footer.
So add an unbound control to the page footer.
Name this control
ctlGrpPages
(don't use the Me! in the control name).
 
H

Hermie

Hello Fred

I try to do the same but it not works, what i did till now is:

1: I put the code behind the report
2: Changed the me.salesperson in me.municipio_referido
3: I put and unbound textbox named: ctlGrpPages
4: I put an unbound textbox with control source = [pages]

saved all and run the report
I only see Page 1 of 19 which was the original page counter textbox
The textbox named ctlGrpPages is empty and textbox with controlsource
=[pages] shows 19

Did I forget something to do?
I like to have the working

Herman
fredg said:
I have added this code to the report, and it still does not keep track of the
pages for the section. The note says

Note: the line Me!Salesperson should be changed to the control name of the
group you wish to track pages for. Me!ctlGrpPages is the name of a control
you should place in the page footer. You can also change this line to
whatever form you wish your page numbers to take.

I think that this is what I am missing, but I do not know where to paste the
ME!ctrlGrpPages?

Thanks

1)
You need to have a control on the report that computes [Pages].
You can use
= [Pages]
and make this control not visible.

2)
No one has any idea what Field your actual report is grouped on.
You need to change (in the code)
GrpNameCurrent = Me!Salesperson
to
GrpNameCurrent = Me!YourControlName

Where YourControlName is the name of the control that the report is
grouped on.

3)
Where do you wish to show the "Page 1 of 3" on the report.
Probably in the Page footer.
So add an unbound control to the page footer.
Name this control
ctlGrpPages
(don't use the Me! in the control name).
 
F

fredg

Hello Fred

I try to do the same but it not works, what i did till now is:

1: I put the code behind the report
2: Changed the me.salesperson in me.municipio_referido
3: I put and unbound textbox named: ctlGrpPages
4: I put an unbound textbox with control source = [pages]

saved all and run the report
I only see Page 1 of 19 which was the original page counter textbox
The textbox named ctlGrpPages is empty and textbox with controlsource
=[pages] shows 19

Did I forget something to do?
I like to have the working

Herman
** snipped **

Hermie,
You evidently have a control that calculates [Pages] already in your
report (the one that prints "Page 1 of 19 " so you do not need the
second one (= [Pages]). You can delete it.

Why your report is not displaying the group pages I have no idea.
Did you place the unbound control [ctlGrpPages] in the Page Footer
section? (Not in the Group footer nor in the Report Footer.)
Is that control's Visible propert set to YES?
Did you step through the code, on line at a time, to see whether it
was accumulating the pages?

Here is the exact code, copied and pasted from my sample database,
that prints the group page of pages in a control in the PAGE FOOTER.

See how it compares to yours.
Pehaps Copy and Paste this directly into your code window.
(Watch out for improper line wrap on the longer lines.)

The only difference should be in the line
GrpNameCurrent = Me!LastName
It should be changed to
GrpNameCurrent = me!municipio_referido
if municipio_referido is the name of the group being counted.
_____________________________

Option Compare Database
Option Explicit

Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
____________________________

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

Dim I As Integer
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page + 1)
ReDim Preserve GrpArrayPages(Me.Page + 1)
GrpNameCurrent = Me!LastName
If GrpNameCurrent = GrpNamePrevious Then
GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
GrpPages = GrpArrayPage(Me.Page)
For I = Me.Page - ((GrpPages) - 1) To Me.Page
GrpArrayPages(I) = GrpPages
Next I
Else
GrpPage = 1
GrpArrayPage(Me.Page) = GrpPage
GrpArrayPages(Me.Page) = GrpPage
End If
Else
Me!ctlGrpPages = "Group Page " & GrpArrayPage(Me.Page) & " of " &
GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent

End Sub

The ctlGrpPages will display "Group Page 1 of 3" , "Group Page 2 of
3", etc.
 
H

Hermie

Hello fred

I compared the code and is exactly the same as yours except the
grpnamecurrent
textbox ctlGrpPages = visible
I deleted textbox =[pages]

But still no see the result of pagenumbering by group?
Does the setting of the group need to be changed?
Now i have:
Field: municipio_referido
Group header: yes
Group footer: no
Group on: each value
Group interval: 1
Keep together: Whole group

Herman


fredg said:
Hello Fred

I try to do the same but it not works, what i did till now is:

1: I put the code behind the report
2: Changed the me.salesperson in me.municipio_referido
3: I put and unbound textbox named: ctlGrpPages
4: I put an unbound textbox with control source = [pages]

saved all and run the report
I only see Page 1 of 19 which was the original page counter textbox
The textbox named ctlGrpPages is empty and textbox with controlsource
=[pages] shows 19

Did I forget something to do?
I like to have the working

Herman
** snipped **

Hermie,
You evidently have a control that calculates [Pages] already in your
report (the one that prints "Page 1 of 19 " so you do not need the
second one (= [Pages]). You can delete it.

Why your report is not displaying the group pages I have no idea.
Did you place the unbound control [ctlGrpPages] in the Page Footer
section? (Not in the Group footer nor in the Report Footer.)
Is that control's Visible propert set to YES?
Did you step through the code, on line at a time, to see whether it
was accumulating the pages?

Here is the exact code, copied and pasted from my sample database,
that prints the group page of pages in a control in the PAGE FOOTER.

See how it compares to yours.
Pehaps Copy and Paste this directly into your code window.
(Watch out for improper line wrap on the longer lines.)

The only difference should be in the line
GrpNameCurrent = Me!LastName
It should be changed to
GrpNameCurrent = me!municipio_referido
if municipio_referido is the name of the group being counted.
 
F

fredg

Hello fred

I compared the code and is exactly the same as yours except the
grpnamecurrent
textbox ctlGrpPages = visible
I deleted textbox =[pages]

But still no see the result of pagenumbering by group?
Does the setting of the group need to be changed?
Now i have:
Field: municipio_referido
Group header: yes
Group footer: no
Group on: each value
Group interval: 1
Keep together: Whole group

Herman

fredg said:
Hello Fred

I try to do the same but it not works, what i did till now is:

1: I put the code behind the report
2: Changed the me.salesperson in me.municipio_referido
3: I put and unbound textbox named: ctlGrpPages
4: I put an unbound textbox with control source = [pages]

saved all and run the report
I only see Page 1 of 19 which was the original page counter textbox
The textbox named ctlGrpPages is empty and textbox with controlsource
=[pages] shows 19

Did I forget something to do?
I like to have the working

Herman
** snipped **

Hermie,
You evidently have a control that calculates [Pages] already in your
report (the one that prints "Page 1 of 19 " so you do not need the
second one (= [Pages]). You can delete it.

Why your report is not displaying the group pages I have no idea.
Did you place the unbound control [ctlGrpPages] in the Page Footer
section? (Not in the Group footer nor in the Report Footer.)
Is that control's Visible propert set to YES?
Did you step through the code, on line at a time, to see whether it
was accumulating the pages?

Here is the exact code, copied and pasted from my sample database,
that prints the group page of pages in a control in the PAGE FOOTER.

See how it compares to yours.
Pehaps Copy and Paste this directly into your code window.
(Watch out for improper line wrap on the longer lines.)

The only difference should be in the line
GrpNameCurrent = Me!LastName
It should be changed to
GrpNameCurrent = me!municipio_referido
if municipio_referido is the name of the group being counted.

Herman,
I don't think I can help any further without actually seeing the
report.
If you wish, send me a sample database with just the report and enough
sample data in the table/query recordsource to test, and I will take a
look at it and email you back.
If you care to do this, send it to
fredg at att dot net (remove the spaces before and after at and dot,
and use the appropriate symbols).
Please mark the subject line "Herman's Database" , otherwise I will
not open it.
 
F

fredg

Hello fred

I compared the code and is exactly the same as yours except the
grpnamecurrent
textbox ctlGrpPages = visible
I deleted textbox =[pages]

But still no see the result of pagenumbering by group?
Does the setting of the group need to be changed?
Now i have:
Field: municipio_referido
Group header: yes
Group footer: no
Group on: each value
Group interval: 1
Keep together: Whole group

Herman

Herman,
I've looked at your database and found the problem.

1) you have a control in the page footer
=[Page]
It should be
=[Pages]

2) You wrote all the code in the Report Code window OK, BUT you did
not set the PageFooter Format event to [Event Procedure], so the code
was never run.

Go back to the database.
In the Page footer, change the =[Page] to =[Pages].
Then Right-Click on the Page Footer.
Select Properties.
Click on the Event tab.
Write [Event Procedure] on that line.
Then click on the little button with three dots that appears on that
line.
The Code window will open.

**** Do NOT disturb the 3 lines Dimming the arrays just under the
Option Explicit. ***

Select all the code that is written in the previous existing
Private Sub PageFooterSection_Format( etc.) event except for that line
and the End Sub line.
Click Ctrl-X to Cut the code.
Then manually delete (use the delete key) the previous existing Sub
PageFooterSecton_Format line and it's End Sub line.

Now paste the cut code into the new Format event.

Run the report. It should work
I'll keep your database for a few days. If you still have a problem,
let me know.
 
H

Hermie

Fred

Many thanks for your help in this case, it works now percfectly. I should
have read more better the code. because it says: PageFooterSection_Format

herman
fredg said:
Hello fred

I compared the code and is exactly the same as yours except the
grpnamecurrent
textbox ctlGrpPages = visible
I deleted textbox =[pages]

But still no see the result of pagenumbering by group?
Does the setting of the group need to be changed?
Now i have:
Field: municipio_referido
Group header: yes
Group footer: no
Group on: each value
Group interval: 1
Keep together: Whole group

Herman

Herman,
I've looked at your database and found the problem.

1) you have a control in the page footer
=[Page]
It should be
=[Pages]

2) You wrote all the code in the Report Code window OK, BUT you did
not set the PageFooter Format event to [Event Procedure], so the code
was never run.

Go back to the database.
In the Page footer, change the =[Page] to =[Pages].
Then Right-Click on the Page Footer.
Select Properties.
Click on the Event tab.
Write [Event Procedure] on that line.
Then click on the little button with three dots that appears on that
line.
The Code window will open.

**** Do NOT disturb the 3 lines Dimming the arrays just under the
Option Explicit. ***

Select all the code that is written in the previous existing
Private Sub PageFooterSection_Format( etc.) event except for that line
and the End Sub line.
Click Ctrl-X to Cut the code.
Then manually delete (use the delete key) the previous existing Sub
PageFooterSecton_Format line and it's End Sub line.

Now paste the cut code into the new Format event.

Run the report. It should work
I'll keep your database for a few days. If you still have a problem,
let me know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top