Table of Contents (1 Viewer)

Hayley Baxter

Registered User.
Local time
Today, 15:32
Joined
Dec 11, 2001
Messages
1,607
I am trying to run a table of contents for my report but as I have never attempted this before I am having some problems. I have set up a table to include the fields for my table of contents and added a module to run this. I don't get any error messages the table of contents just doesn't appear.

Here is the code:

Option Explicit
Option Compare Database
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 = "Description"
End Function


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!Description = tocentry
toctable![page number] = Rpt.Page
toctable.Update
End If
End Function

Has anyone used this before or can suggest where I might be going wrong?

Thanks
Hay
 

Hayley Baxter

Registered User.
Local time
Today, 15:32
Joined
Dec 11, 2001
Messages
1,607
It would appear that the code is actually working just not the way I hoped it would unless I am missing something. I take it there is no way of running your search form and have the tables of contents appear as the first page of your search results report giving all the listings for what is on what page? It seems to me that the table of contents report must be run and printed separately to the report you are creating the table of contents for unless I am mistaken? I don't really like the way this currently works so any suggestions would be great.

Thanks
Hay
 

Users who are viewing this thread

Top Bottom