Reset page number in a group

G

Guest

I tried the method stated below. However, the result came out as page 1 of 1
and page 2 of 2 when there is two pages in the group. The result should be
page 1 of 2 and page 2 of 2. Where did i go wrong? Pls help. Thank you =)

fredg said:
Hi.. I have reset the page number for each group in a report. However, I am
unable to calculate the total page number for each group.
For example: For two groups, the first group got one page, second group got
three pages. I want to set the page number to appear for first group: page
1/1. For second group: page 1/2 and page 2/2. Pls help. Thanks.

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

Things to make sure of:
1) Add a control to the page Footer that computes [Pages], i.e.
= [Pages]
You can make this control not visible if you wish.

2) Add an unbound control to the Page Footer.
Name this control "ctlGrpPages"

3) Paste the code into the Page Footer Format event.

4) In the code, change Me!Salesman to
Me![Name of the control used to group by]
 
D

Douglas J Steele

I can assure you that sample code works, so without knowing what changes you
made to it, I doubt anyone will be able to tell you where you went wrong.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hwee said:
I tried the method stated below. However, the result came out as page 1 of 1
and page 2 of 2 when there is two pages in the group. The result should be
page 1 of 2 and page 2 of 2. Where did i go wrong? Pls help. Thank you =)

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

Things to make sure of:
1) Add a control to the page Footer that computes [Pages], i.e.
= [Pages]
You can make this control not visible if you wish.

2) Add an unbound control to the Page Footer.
Name this control "ctlGrpPages"

3) Paste the code into the Page Footer Format event.

4) In the code, change Me!Salesman to
Me![Name of the control used to group by]
Hi.. I have reset the page number for each group in a report. However, I am
unable to calculate the total page number for each group.
For example: For two groups, the first group got one page, second group got
three pages. I want to set the page number to appear for first group: page
1/1. For second group: page 1/2 and page 2/2. Pls help. Thanks.
 
G

Guest

Thank you for replying. I didn't change the code. Because in my report, most
sections only have one page. So it's fine to have page 1 of 1. However, for
section with two or more pages, the total number of pages is wrong. The only
thing i didn't follow is that i reset the page number for each section before
writing the code. Should i change something to the GrpArrayPages?

Douglas J Steele said:
I can assure you that sample code works, so without knowing what changes you
made to it, I doubt anyone will be able to tell you where you went wrong.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hwee said:
I tried the method stated below. However, the result came out as page 1 of 1
and page 2 of 2 when there is two pages in the group. The result should be
page 1 of 2 and page 2 of 2. Where did i go wrong? Pls help. Thank you =)

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

Things to make sure of:
1) Add a control to the page Footer that computes [Pages], i.e.
= [Pages]
You can make this control not visible if you wish.

2) Add an unbound control to the Page Footer.
Name this control "ctlGrpPages"

3) Paste the code into the Page Footer Format event.

4) In the code, change Me!Salesman to
Me![Name of the control used to group by]

Hi.. I have reset the page number for each group in a report. However, I am
unable to calculate the total page number for each group.
For example: For two groups, the first group got one page, second group got
three pages. I want to set the page number to appear for first group: page
1/1. For second group: page 1/2 and page 2/2. Pls help. Thanks.
 
D

Douglas J Steele

Did you follow all of the steps Fred layed out?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hwee said:
Thank you for replying. I didn't change the code. Because in my report, most
sections only have one page. So it's fine to have page 1 of 1. However, for
section with two or more pages, the total number of pages is wrong. The only
thing i didn't follow is that i reset the page number for each section before
writing the code. Should i change something to the GrpArrayPages?

Douglas J Steele said:
I can assure you that sample code works, so without knowing what changes you
made to it, I doubt anyone will be able to tell you where you went wrong.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hwee said:
I tried the method stated below. However, the result came out as page
1 of
1
and page 2 of 2 when there is two pages in the group. The result should be
page 1 of 2 and page 2 of 2. Where did i go wrong? Pls help. Thank you =)

:

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

Things to make sure of:
1) Add a control to the page Footer that computes [Pages], i.e.
= [Pages]
You can make this control not visible if you wish.

2) Add an unbound control to the Page Footer.
Name this control "ctlGrpPages"

3) Paste the code into the Page Footer Format event.

4) In the code, change Me!Salesman to
Me![Name of the control used to group by]

Hi.. I have reset the page number for each group in a report.
However,
I am
unable to calculate the total page number for each group.
For example: For two groups, the first group got one page, second group got
three pages. I want to set the page number to appear for first
group:
page
1/1. For second group: page 1/2 and page 2/2. Pls help. Thanks.
 
G

Guest

Yes. I write the code accordingly. Here is the code i wrote in microsoft
visual basic.

Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer


Private Sub PageFooterSection_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!ctlGrpPages
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

Plus i created a textbox with control sourse =[Pages] and i make this not
visible. Created another textbox named ctlGrpPages. The code is pasted.


Douglas J Steele said:
Did you follow all of the steps Fred layed out?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hwee said:
Thank you for replying. I didn't change the code. Because in my report, most
sections only have one page. So it's fine to have page 1 of 1. However, for
section with two or more pages, the total number of pages is wrong. The only
thing i didn't follow is that i reset the page number for each section before
writing the code. Should i change something to the GrpArrayPages?

Douglas J Steele said:
I can assure you that sample code works, so without knowing what changes you
made to it, I doubt anyone will be able to tell you where you went wrong.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I tried the method stated below. However, the result came out as page 1 of
1
and page 2 of 2 when there is two pages in the group. The result should be
page 1 of 2 and page 2 of 2. Where did i go wrong? Pls help. Thank you =)

:

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

Things to make sure of:
1) Add a control to the page Footer that computes [Pages], i.e.
= [Pages]
You can make this control not visible if you wish.

2) Add an unbound control to the Page Footer.
Name this control "ctlGrpPages"

3) Paste the code into the Page Footer Format event.

4) In the code, change Me!Salesman to
Me![Name of the control used to group by]

Hi.. I have reset the page number for each group in a report. However,
I am
unable to calculate the total page number for each group.
For example: For two groups, the first group got one page, second
group got
three pages. I want to set the page number to appear for first group:
page
1/1. For second group: page 1/2 and page 2/2. Pls help. Thanks.
 

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