Access 2007 Table of Contents

  • Thread starter Thread starter Peter
  • Start date Start date
Peter said:
Has anyone been able to produce a table of contents for a report in Access
2007; I have had no luck with the code at
http://support.microsoft.com/?id=210269.

As far as I can see there's no reason why that code shouldn't work.
What is the problem you are having? Any error messages?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Peter said:
Has anyone been able to produce a table of contents for a report in Access
2007; I have had no luck with the code at
http://support.microsoft.com/?id=210269.

Tony --

I am using my own database -- not Northwind.

Under the Macro tab, I created a module (named mod Table of Contents) with
the following 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

When I try to run the report, I get the following error: "Microsoft Office
Access can't find the object 'InitToc().' "

-- Peter
 
Tony Toews said:
Insert the word Public in front of Function


Same here

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Tony --

I added Public (followed by a space) in front of two "Function". I still
get the same error.

-- Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top