I came across a good KB article on this and tried to use the directions to create a TOC. Somehow, the result is half baked as the table created does not quite list all depts. I was wondering if someone had any experience with this. I am using the following process. I hope I am not missing any step.
Created a table 'Table of Contents with fields Department and Page Number
Added a module with the following;
In the report, created a department header and added following on the On Print event:
=UpdateToc([Department],[Report])
The end result is that I managed to get page numbers for three departments but missed on all the rest.
Will appreciate some help.
Created a table 'Table of Contents with fields Department and Page Number
Added a module with the following;
Code:
Option Compare Database
Option Explicit
Dim db As Database
Dim toctable As Recordset
Function InitToc()
' Called from the OnOpen property of the report.
' Opens the database and the table for the report.
Dim qd As QueryDef
Set db = CurrentDb()
' Delete all previous entries in Table of Contents table.
Set qd = db.CreateQueryDef _
("", "Delete * From [Table of Contents]")
qd.Execute
qd.Close
' Open the table.
Set toctable = db.OpenRecordset("Table Of Contents", _
DB_OPEN_TABLE)
toctable.Index = "Department"
End Function
Code:
Function UpdateToc(tocentry As String, Rpt As Report)
' Call from the OnPrint property of the section containing
' the Table Of Contents Description field. Updates the Table Of
' Contents table.
toctable.Seek "=", tocentry
If toctable.NoMatch Then
toctable.AddNew
toctable!Department = tocentry
toctable![page number] = Rpt.Page
toctable.Update
End If
End Function
=UpdateToc([Department],[Report])
The end result is that I managed to get page numbers for three departments but missed on all the rest.
Will appreciate some help.
Last edited by a moderator: