Hello all!
For my report that has 'ShopName' grouping which appears in detail section I'm trying to combine a table of contents tabular one-page subform that would be located at the forum header section. Searching through Microsoft help I have found this code to be used for creating a table of contents:
Table: Table Of Contents
-------------------------------
Field Name: Description
Data Type: Text
Field Size: 15
Indexed: Yes (No Duplicates)
Field Name: Page Number
Data Type: Number
Field Size: Long Integer
Indexed: No
New Module:
Report's OnOpen Event:
=InitToc()
On the report's detail OnPrint event:
=UpdateToc([ShopName],Report)
There are 2 problems with this code:
1. I have to open the report, and go through all its pages in order to have the table of contents to be combined
correctly.
2. I can't view the table of contents that is on the report's header section when I open the report because it isn't combined yet! The table is deleted each time I open the report.
Can you assist me in combining a code that will display the table of contents on the forum's header section in a tabular subform, preferably without the need to go through all the reports pages in order to have it created?
Much thanks,
inso.
For my report that has 'ShopName' grouping which appears in detail section I'm trying to combine a table of contents tabular one-page subform that would be located at the forum header section. Searching through Microsoft help I have found this code to be used for creating a table of contents:
Table: Table Of Contents
-------------------------------
Field Name: Description
Data Type: Text
Field Size: 15
Indexed: Yes (No Duplicates)
Field Name: Page Number
Data Type: Number
Field Size: Long Integer
Indexed: No
New Module:
Code:
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 = "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
Report's OnOpen Event:
=InitToc()
On the report's detail OnPrint event:
=UpdateToc([ShopName],Report)
There are 2 problems with this code:
1. I have to open the report, and go through all its pages in order to have the table of contents to be combined
correctly.
2. I can't view the table of contents that is on the report's header section when I open the report because it isn't combined yet! The table is deleted each time I open the report.
Can you assist me in combining a code that will display the table of contents on the forum's header section in a tabular subform, preferably without the need to go through all the reports pages in order to have it created?
Much thanks,
inso.