Another Table of Contents Problem

R

Rob

I have created a report and want to set up a Table of Contents. I have
looked at the posts and have the following code:

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

Dim qd As DAO.QueryDef

Set db = CurrentDb() 'Resets the page number back to 1
intPageCounter = 1
'Delete all previous entries in Table of Contents table.
Set qd = db.CreateQueryDef("", "Delete * From [tblTOCDirectory]")
qd.Execute
qd.Close 'Open the table.
Set TocTable = db.OpenRecordset("tblTOCDirectory", dbOpenTable)
TocTable.Index = "DESCRIPTION"
End Function

Function UpdateToc(TocEntry As String, Rpt As Report)
With TocTable
.Seek "=", TocEntry

If .NoMatch Then
.AddNew
![FULLNAME] = TocEntry
![PageNumber] = Rpt.Page
.Update
End If
End With
End Function

Function UpdatePageNumber()

intPageCounter = intPageCounter + 1

End Function


All works well except the UpdateToc Function. The tblTOCDirectory has the
two field names: Description and PageNumber and I have a FULLNAME Header on
the report that comes from a make table query and the full name is a
combination of two fields: Name1 and Name2. There is a subreport in the
report but I don't believe that is a problem for generating the Table of
Contents (tblTOCDirectory). I get an error stating that an object is required
when I reach the .Seek "=", TocEntry command and I can't figure out what is
wrong. I have in the OnPrint property of the FullName Header
"=UpdateToc([FullName],[Report])" Can someone please help?
 

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

Top