Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Page Numbers by Group

608 views
Skip to first unread message

Michael McGroarty

unread,
Mar 24, 2005, 12:57:10 PM3/24/05
to
I have created a report that is generated statewide, grouped by district. I
would like to display page numbers within each group and perferably total
pages in group (Page X of Y). Any suggestions?

Thanks!
Mike

siaj

unread,
Mar 24, 2005, 1:35:02 PM3/24/05
to
Mike ..

You can drag the Globals!PageNumber and Globals!Totalpages from the
expression window of the IDE. for (Page X of Y ) you can use formula ="(Page
"&Globals!PageNumber & "of"Globals!TotalPages &" )"

Did I answer your question..

Cheers,
siaj..

Michael McGroarty

unread,
Mar 24, 2005, 1:51:04 PM3/24/05
to
Thank you, but not really. The report is 800 some pages. It is broken down
by district (1-3 pages per district). I would like to "restart" numbering
the pages for each district.

For example on page 67 of the report where District Z's two page group
begins, I would like to display Page 1 of 2 on page 67 and Page 2 of 2 on
page 68.

Parametizing the report and printing each district individually is not an
option as there are more than 800 districts in the state.

Thanks again!
Mike

Michael McGroarty

unread,
Mar 24, 2005, 4:39:05 PM3/24/05
to
I was mostly able to solve this myself. What I did was add a DistrictCode
txtbox to my District list. Then I added the following embedded code to the
report:

Shared gPageNo as Integer = 0
Shared gCurDistrict as String = "00000"
Shared gFirstCall as Integer = 0

Function IncPage(ByVal CurDistrict as String) as Integer

If gFirstCall = 0 Then
gFirstCall = 1
gPageNo = 1
Else
If CurDistrict = gCurDistrict Then
gPageNo = gPageNo + 1
Else
gCurDistrict = CurDistrict
gPageNo = 1
End if
End If

Return gPageNo

End Function
From the Page Footer, I have a textbox where I call the IncPage function
referencing the value of the txtbox in the list like this:

="Page: " & Code.IncPage(First(ReportItems!DistrictCode_1.Value))

I'm not sure why yet, but before I placed the gFirstCall If statement in
there the first page was always starting at Page 2. Every other page showed
the correct page though. Wierd.

Thanks again!
Mike

Harry

unread,
Apr 19, 2005, 4:38:16 AM4/19/05
to
Where is the code embedded into the report?

Thanks
Harry

Dave Sundell

unread,
May 18, 2005, 9:10:03 AM5/18/05
to
Did you ever get the function to work? I tried it but I get an error because
it says you cannot reference a field within page footers. I do the function
call within the page footer.

Michael McGroarty

unread,
May 18, 2005, 9:20:01 AM5/18/05
to
Go to Report Properties and choose the Code tab. Place the code there.

Dave Sundell

unread,
May 18, 2005, 9:26:05 AM5/18/05
to
I have the function there but when I reference the function from a textbox in
the page footer, the parm in the function is a field from the report and you
can't reference a field in the page footer. I get an expression error "The
value expression for the textbox ‘textbox61’ refers to a field. Fields
cannot be used in page headers or footers."

Michael McGroarty

unread,
May 18, 2005, 9:28:07 AM5/18/05
to
I have a hidden textbox in the body that's bound to the data field. Then I
reference the textbox using the ReportItems collection from within the footer.

DistrictCode_1 is the hidden textbox in the body of the report. Its value is:
=First(Fields!DistrictCode.Value)

In the value of the footer page number textbox below, DistrictCode_1 refers
to the hidden textbox in the body:
="Page: " & Code.IncPage(First(ReportItems!DistrictCode_1.Value))

Mike

Michael McGroarty

unread,
May 18, 2005, 9:41:03 AM5/18/05
to
I have a hidden textbox in the body that's bound to the data field. Then I
reference the textbox using the ReportItems collection from within the footer.

DistrictCode_1 is the hidden textbox in the body of the report. Its value is:
=First(Fields!DistrictCode.Value)

In the value of the footer page number textbox below, DistrictCode_1 refers
to the hidden textbox in the body:

="Page: " & Code.IncPage(First(ReportItems!DistrictCode_1.Value))

I never did get that first page in the first group to start at 1. Let me
know if you figure that one out.

Mike

Dave Sundell

unread,
May 18, 2005, 10:00:01 AM5/18/05
to
Thanks for replying by the way. I am still working on how to get a bound
textbox item in the report body so that it appears as a report item and not a
field item when trying to reference it in the page footer text box. My report
body is made up of a huge list box that even contains a table within it. So,
that is where I am at.

Have you heard if Mcirosoft plans to make improvements on page numbering
control with report grouping? I posted a item addressing this question.

Michael McGroarty

unread,
May 18, 2005, 12:28:11 PM5/18/05
to
Play around with the values of the global variables. Sometimes, it seems
that the function is actually being called twice on a page although I don't
know how this is possible. I remember changing the initial values of the
global variables to get them to come out correct, but I never got around the
problem of the first page in the report starting at page 2.

I don't work for Microsoft, so I really have no idea what they are planning.
I would like to see a lot of changes in Reporting Services as I pushed
pretty hard to get it to be used in my organization.

"Dave Sundell" wrote:

> Got it. Now have to work on getting the page numbers to come out right. It
> comes out as:
> Group 1 (has 4 pages)
> Page 1
> Page 1
> Page 2
> Page 3
> Group 2 (also has 4 pages)
> Page 1
> Page 1
> Page 2
> Page 3
>
> I also would have liked the total pages on each page, e.g. Page 1 of 4, but
> I realize that won't be possible, since Reporting Services operates in a
> single pass report generation methodology. That is why am asking if in the
> next release there will be greater control over this areas.
>
> "Michael McGroarty" wrote:
>
> > Just put a text box on the page and make its value:
> > =First(Fields!YourFieldHere.Value)
> >
> > I have no idea what Microsoft's plans are.

Dave Sundell

unread,
May 18, 2005, 12:40:11 PM5/18/05
to
Got it. Now have to work on getting the page numbers to come out right. It
comes out as:
Group 1 (has 4 pages)
Page 1
Page 1
Page 2
Page 3
Group 2 (also has 4 pages)
Page 1
Page 1
Page 2
Page 3

I also would have liked the total pages on each page, e.g. Page 1 of 4, but
I realize that won't be possible, since Reporting Services operates in a
single pass report generation methodology. That is why am asking if in the
next release there will be greater control over this areas.

"Michael McGroarty" wrote:

> Just put a text box on the page and make its value:
> =First(Fields!YourFieldHere.Value)
>
> I have no idea what Microsoft's plans are.
>
> "Dave Sundell" wrote:
>

Dave Sundell

unread,
May 18, 2005, 12:42:15 PM5/18/05
to
Got the page numbers working. I created an InitPage function and placed this
in the header.For testing purposes I had a texhbox in the header and the
footer to display the value being passed to the function and I noticed it
blank on the 2nd and subsequent pages. So I tweaked the code accordingly.

Shared gPageNo as Integer = 0

Shared gCurClock as String = "00000"


Shared gFirstCall as Integer = 0

Function InitPage(ByVal CurClock as String) as Integer

If gFirstCall = 0 Then

gFirstCall = gFirstCall +1
gPageNo = 0
gCurClock = CurClock
Else
gFirstCall = gFirstCall +1
If CurClock = gCurClock Then
gPageNo = gPageNo
Else
If CurClock.length > 0 then
gCurClock = CurClock
gPageNo = 0
Else
gCurClock = gCurClock
End if
End if
End If

Return gPageNo
End Function
Function IncPage(ByVal CurClock as String) as Integer
If gPageNo = 0 then


gPageNo = gPageNo + 1

else
If gFirstCall = 1 Then
gPageNo = 1
gCurClock = CurClock
Else


gPageNo = gPageNo + 1

End If
End If

Return gPageNo
End Function

Michael McGroarty

unread,
May 18, 2005, 12:55:56 PM5/18/05
to
Just put a text box on the page and make its value:
=First(Fields!YourFieldHere.Value)

I have no idea what Microsoft's plans are.

unknown

unread,
Jan 26, 2010, 3:26:07 PM1/26/10
to
none of this helped sry maybe my school blocked it

From http://www.developmentnow.com/g/115_2005_3_0_0_457102/Page-Numbers-by-Group.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

0 new messages