Table of Contents

J

JeffH

I am having difficulty establishing a table of contents for a report that I
have. I have used the code suggested in an article posted here and it keeps
erroring out. I have reviewed the code and there are no mistakes.

Here is the article I am referring to:
http://support.microsoft.com/default.aspx?scid=kb;en-us;210269.

My first error is at line

Set TocTable = db.OpenRecordset("Table of Contents", dbOpenTable)

I changed the code to use "dbOpenDynaset" as below and then I get past
the first line. See below.
Set TocTable = db.OpenRecordset("Table of Contents", dbOpenDynaset)

Then the below line errors out.

TocTable.Index = "Description"

I get a run time error 3251, "Operation is not supported by this type of
object"

Where do I go from here. I'm an Access newbie and VB code is a challenge
right now.

I am using the function on a very simple report right now in order to get a
table of contents. The actually report I need it for has a subreport in it
for which the table of contents is needs. So it only gets more complicated
if I get this 1st part figured out.

Help?
 
W

Wayne Morgan

The error on the .Index is because you opened the recordset as a Dynaset
instead of a Table. In the function UpdateTOC, the index that was set here
would be used for the Seek.

When you did the Dim statements, did you include the "DAO."? This is a DAO
recordset and Access will use ADO by default. If you haven't already, you
need to set a reference to DAO. Once you do that, specifying DAO in the Dim
statements will prevent Access from trying to use the wrong type of
recordset.

To set a reference to DAO, open the code editor (Alt+F11) and go to
Tools|References. Look through the checked references. If you don't have one
set to "Microsoft DAO 3.6 Object Library", then scroll down the list and
check it. Click Ok to close the dialog box then try the code again.
 

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