Generating page numbers in table of contents

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have arountine that creates a ToC from a database and now need to add page numbers
The approach I have taken is to use a table contiing 2 columns, the ToC entry and the page number
I can obtain the page number by using Page (reserved word).
To update my ToC table I use a Print Event
Problem
The page number Page is generated at print time or on display if using preview. I therefor either have to print the page report twice the first time to get the system to generate page numbers that are then output to the file on each rendering of the page OR use a preview and manually scroll through to the end of the report. This also uses the Print Event and my page numbers are created correctly
I have tried using another Event e.g. Format, but the Page is not created correctly so one idea I had (others would be welcome) is to find a way to preview but programmatically scroll through to the end of the report and then allow the user to select Print. I do not need to print automatically as I need the dialog box to select a printer etc. so preview mode is fine but I do not want the user to have to manually scroll through to the end even by selecting the >| butto
Help/advice appreciated - Thanks
 
Sorry - I didn't mention that the report is made up of a number of sub-reports some of which also have sub-reports. I think it is this that is causing the On Format to get the page numbers incorrect although I always refer to the main report Page
 
I have a similar problem with the table of contents not reporting the correct page number. I am running the report twice to generate the table of contents page numbers. What do you think? Here is my code

Option Compare Databas
Option Explici

Dim DB As Objec
Dim toctable As Objec

Function InitToc(
' Called from the OnOpen property of the report
' Opens the database and the table for the report

Set DB = CurrentDb(

DB.Execute "DELETE * FROM tblTableOfContents;

' Opens the table
Set toctable = DB.OpenRecordset("tblTableOfContents"
toctable.Index = "Description

End Functio


Function UpdateToc(tocentry As String, Rpt As Report

' Called from the OnPrint property of the section containin
' the Table Of Contents entry. Updates the Table Of Content
' entry

toctable.Seek "=", tocentr

If toctable.NoMatch The
toctable.AddNe
toctable!DESCRIPTION = tocentr
toctable![page number] = Rpt.Pag
toctable.Updat
End I


End Functio
 
Back
Top