I started with the code from trusty ol' microsoft kb article 210269
Looks pretty straight forward and very much needed in this case.
Put in the code with the appropriate changes.
Try to run it and get:
Run-time error '3800':
'IndexEntry' is not an index in this table.
Debug shows the culprit as the line:
TocTable.Index = "IndexEntry"
I check the table def and spelling properties and the original article as well
as searched for already posted solutions for other with the problem.
The concept is easy. When the report opens delete the records in the old index table.
As each record is printed, update the table with page numbers in the report to build
another report later.
So far I cannot get past the init function called by report open. If I comment out the
line, sure enough it complains that there is no index. The field is defined as an index
in the table.
I am certainly not as experienced as most here and I have this haunting feeling I am
overlooking really simple and basic.
All suggestions and assistance will be welcome and valued.
The code from my module is:
Declarations:
Option Explicit
Dim db As DAO.Database
Dim TocTable As DAO.Recordset
Dim intPageCounter As Integer
The function with the run-time error:
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 [Toc Table]")
qd.Execute
qd.Close
'Open the table.
Set TocTable = db.OpenRecordset("TOC Table", dbOpenTable)
'This line returns the error
TocTable.Index = "IndexEntry"
End Function
TOC Table has two fields
IndexEntry is a text field, indexed with no duplicates.
I do not no why a defined index in a table cannot be an index for a recordset from that table.
Thank you for you time and consideration.
Regards,
Manse
Looks pretty straight forward and very much needed in this case.
Put in the code with the appropriate changes.
Try to run it and get:
Run-time error '3800':
'IndexEntry' is not an index in this table.
Debug shows the culprit as the line:
TocTable.Index = "IndexEntry"
I check the table def and spelling properties and the original article as well
as searched for already posted solutions for other with the problem.
The concept is easy. When the report opens delete the records in the old index table.
As each record is printed, update the table with page numbers in the report to build
another report later.
So far I cannot get past the init function called by report open. If I comment out the
line, sure enough it complains that there is no index. The field is defined as an index
in the table.
I am certainly not as experienced as most here and I have this haunting feeling I am
overlooking really simple and basic.
All suggestions and assistance will be welcome and valued.
The code from my module is:
Declarations:
Option Explicit
Dim db As DAO.Database
Dim TocTable As DAO.Recordset
Dim intPageCounter As Integer
The function with the run-time error:
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 [Toc Table]")
qd.Execute
qd.Close
'Open the table.
Set TocTable = db.OpenRecordset("TOC Table", dbOpenTable)
'This line returns the error
TocTable.Index = "IndexEntry"
End Function
TOC Table has two fields
IndexEntry is a text field, indexed with no duplicates.
I do not no why a defined index in a table cannot be an index for a recordset from that table.
Thank you for you time and consideration.
Regards,
Manse