Hi Folks,
I've previously created a Table of Contents using one field from another report's recordset. Now, (of course) my user wants additional information. This is a drug database that keeps up with various info including Generic name and Brand name. My current Table of Contents is for Generic name and the user wants Brand listed in the same column as well. My problem is that when I run the source report the function only populates the Brand field in the aatoc table for the first page of the source report but the Generic field is populated just fine. Here are my functions. Any suggestions would be greatly appreciated.
Option Compare Database
Option Explicit
Dim DB As DAO.Database
Dim TocTable As Recordset
Dim TocTable_B As Recordset
Dim TocEntry As String
Dim TocEntry_B As String
Function InitToc()
' Called from the OnOpen property of the report.
' Opens the database and the table for the report.
Set DB = CurrentDb()
DB.Execute "DELETE * FROM [aatoc];"
'Delete all previous entries in "aatoc" table.
Set TocTable = DB.OpenRecordset("aatoc", dbOpenTable)
TocTable.INDEX = "Generic"
Set TocTable_B = DB.OpenRecordset("aatoc", dbOpenTable)
TocTable_B.INDEX = "BRAND"
End Function
Function UpdateToc(TocEntry As String, TocEntry_B As String, Rpt As Report)
' Called from the OnPrint property of the section containing
' the Table Of Contents entry. Updates the Table Of Contents
' entry in the "aatoc" table.
TocTable.Seek ">", TocEntry
TocTable_B.Seek ">", TocEntry_B
If TocTable.NoMatch Then
TocTable.AddNew
TocTable!Generic = TocEntry
TocTable![PAGE NUMBER] = Rpt.PAGE
TocTable.Update
End If
If TocTable_B.NoMatch Then
TocTable_B.AddNew
TocTable_B!BRAND = TocEntry_B
TocTable_B![PAGE NUMBER] = Rpt.PAGE
TocTable_B.Update
End If
End Function
I've previously created a Table of Contents using one field from another report's recordset. Now, (of course) my user wants additional information. This is a drug database that keeps up with various info including Generic name and Brand name. My current Table of Contents is for Generic name and the user wants Brand listed in the same column as well. My problem is that when I run the source report the function only populates the Brand field in the aatoc table for the first page of the source report but the Generic field is populated just fine. Here are my functions. Any suggestions would be greatly appreciated.
Option Compare Database
Option Explicit
Dim DB As DAO.Database
Dim TocTable As Recordset
Dim TocTable_B As Recordset
Dim TocEntry As String
Dim TocEntry_B As String
Function InitToc()
' Called from the OnOpen property of the report.
' Opens the database and the table for the report.
Set DB = CurrentDb()
DB.Execute "DELETE * FROM [aatoc];"
'Delete all previous entries in "aatoc" table.
Set TocTable = DB.OpenRecordset("aatoc", dbOpenTable)
TocTable.INDEX = "Generic"
Set TocTable_B = DB.OpenRecordset("aatoc", dbOpenTable)
TocTable_B.INDEX = "BRAND"
End Function
Function UpdateToc(TocEntry As String, TocEntry_B As String, Rpt As Report)
' Called from the OnPrint property of the section containing
' the Table Of Contents entry. Updates the Table Of Contents
' entry in the "aatoc" table.
TocTable.Seek ">", TocEntry
TocTable_B.Seek ">", TocEntry_B
If TocTable.NoMatch Then
TocTable.AddNew
TocTable!Generic = TocEntry
TocTable![PAGE NUMBER] = Rpt.PAGE
TocTable.Update
End If
If TocTable_B.NoMatch Then
TocTable_B.AddNew
TocTable_B!BRAND = TocEntry_B
TocTable_B![PAGE NUMBER] = Rpt.PAGE
TocTable_B.Update
End If
End Function