Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show the total number of pages in a report before it is opened 2

Status
Not open for further replies.

mobile2

Programmer
Dec 19, 2002
38
GB
I would like my users to know how many pages there are in a report by prompting them with a message box when they open the report
 
In the Report Footer Format event or Print event, you can put a message box that says.

MsgBox "This report is " & Me.Pages & " long."

That should do it.

Paul
 
This sounded really neat so I just tried it. When I run the report I get the "Me.pages" text instead of the page count. Am I missing the point?
Thanks!
 
Post your message box code here. It looks like you have Me.Pages inside the quote marks.

Paul
 
This report is & Me.Pages & long.

"This report is " & Me.Pages & " long."
I tried both of these in a macro that is called from the report footer format event. The only difference is the quotes or lack of them in the message box.



 
Don't use a macro. Use the messagebox method. Copy this directly in the report footer format event.

MsgBox "This report is " & Me.Pages & " long"

The macro doesn't know what Me. is and just sets the whole thing up as a string regardless you how you punctuate it.

Paul
 
That's the first thing I tried. I get a message "Change Log can't find the macro "msgBox"ThisReport is"& Me."
The macro or its group doesn't exist or is new but hasnto been saved.

This mention to macros is why I then tried use a macro.
(And why won't access let you highlight and copy an error message. I had to copy that down with a PENCIL.)

Thanks.
 
Hum...It sounds like maybe you put the code on the line next to the Report Footer Event and therefore the report is looking for a macro by that name. Here's what you do. Open your report in Design View. Open the properties window for the Report Footer. Click on the line next to the Format Event and you will see a dropdown arrow and an elipsis(the button with three dots ... on it). Click on that button. Then you will get a window that has three buttons in it. Click the Code Builder button and this will open the Format Event for the Report Footer. In between the Private Sub and End Sub lines, insert the MsgBox line that I posted above. Then when you close that window, make sure that the line next to the Format event has the words [Event Procedure] showing on it. That should take care of it.

Paul
 
Thanks, that helped a lot. I do get a message box now. It says 0 pages (for a 29 page report), but am grateful for progress! I've tried moving it to a couple different report segments. Sometimes it says 0 pages until I click the page navigation button, then updates to the correct number of pages. I'll keep trying things.
 
Sorry, put it in the PageFooter Print event. Follow the same procedure as before to get to the event procedure. Make sure you take it out of the Report Footer event also. This will give you what you want.

Paul
 
I hadn't gotten around to trying there yet and, Yippee, it works! That is an interesting exercise to see how the same thing works differently when it is called from different places.
Thanks bunches!
 
I was a little surprised that it worked there and not in the Report Footer. I would have thought the results would have been 0 for the Page and a number for the Report event but it works and that's good.

Paul
 
What I just discovered is that if you print to the screen you get this little message every time you click forward a page. So on a 30 page report...
 
You can use this in the ReportHeader Format Event. It should do what you need and avoid the extra message boxes.

Paul

Static I As Integer
If I = 1 Then
MsgBox "there are " & Me.Pages & " in the report"
I = I + 1
Else
I = I + 1
End If
 
Thanks, Paul!
I wonder if the original poster of this question (mobile2)is way ahead of me on this topic. Haven't heard from him/her through all of this. Anyway I have learned a lot from this question and all others in the forum. Thank you to all participants for the very informative posts.
[pc2]
 
I wouldn't worry about mobile2. They don't seem to have much to say in any of their posts. Glad it helped.

Paul
 
I am a new user to tek-tips but was really surprised to see the response to a thread I started. This is a really good way of sharing knowledge and I am really impressed with all the expert advice people have given me. I will try and make my responses a bit more interesting in future and stop taking things too seriously.
 
Welcome back mobile2. I would suggest you start by reading some of the FAQ's that help instruct you in which forums will best get you the answers you need and just the general procedures around here and then have fun. That's what we're here for.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top