Saving page number from report

  • Thread starter Thread starter Phillip
  • Start date Start date
P

Phillip

Hi,
I have about a 200 page report that gets its data using every record in a
table. I would like to have a field in each record for a page number and
have the field filled as the report prints. I can then use that
information to print various indexes and table of contents. Is there a way
to assign the page number to each record as the report pirnts? If no is
there a better way?
Thanks,
 
You can create a table for holding the page numbers. Then put code in the
report's sections to write the values you need to that table.

In the Report's Open event procedure, delete any existing entries in the
table (from last time the report was run.), and OpenRecordset to append the
values.

In the Print event of the Detail section, AddNew to the recordset, to record
the primary key value and page number or whatever you need.

In the report's Close event, close your recordset.
 
Thanks for your response,
Is there no way to place the page number in the table that report was
printed from?
Thanks,
 
You can't get the page numbers into the table until the report pages have
been run, so the best you can to is to make another report as the table of
contents.
 
Hi again,
Let me ask another question: I have a form with a command button that calls
the report. The form also has sort buttons that the user can click on to
sort the form on various feilds before they print the report. Is it possible
to have code in the form that would place the page numbers in the main table
based on the sort button selected? The pages in the report are printed in
the same order as the records shown on the form.
It would be very easy for the indexing I want to do if I could get the page
numbers in the main table.
Thanks,
 
It may be possible to do that, but that are many things that may may it
impractical, e.g.:

a) Sections CanGrow or CanShrink, so you don't know how many records will
actually fit on each page.

b) You'd need to take into account the number of Group Header and Group
Footer sections on each page.

c) Many properties on the report may mess this up, e.g. Keep Together
property of the sections, and the Keep With Next (or keep all together)
setting for the group headings, or Page Break Before etc
 
Back
Top