Dynamic Table of Contents

I am not sure if this is even possible, and I am almost positive it is going to resort me to have to figure this out in VB but I am wanting to create a table of contents that also includes the page number. I want the number to automatically update to the correct page in case if it changes.

Is this possible?

Post your answer or comment

comments powered by Disqus
Does anyone know how I can have a 2 - page report header (page 1 is for the title etc. and page two for a table of contents)?

I have a large report (500 pages) and would like to provide a table of contents and an index.

The table of contents would be based on groupings in the main report and the Index would be based on line items in a subreport.

Any ideas?

Hi All:

long time no thread! Running Access 2003.

I have a report with group headings that starts each group on a new page and pages are numbered.

How can I create a table of contents showing group heading and page number for each group?


Thanks to all for the great content on this site - I've resolved a lot of issues by reviewing previous posts.

I've searched this forum pretty thoroughly and couldn't find the answer to the following:
I have a report that generates a document that replaces an older MS Word-based template. I've been able to replicate everything in the template except for the table of contents. I've found reference to a solution for populating a table of contents table based on the pages identified while printing the report (http://support.microsoft.com/?id=210269), but this requires that the table of contents report then be printed separately from the main report. I'm looking for a way to generate the content as a single document.

I can imagine two potential paths to investigate:
1. Somehow opening, print previewing all pages, and closing the report to populate the table of contents table, then opening the report again and not updating the table of contents.
2. generating the table of contents via some other mechanism (e.g., not basing it off data stored in a table).

Subreports, VBA, macros, and voodoo are fair game. Appreciate any help you can offer in advance.


Dear All,

What is the best way to create an automated table of content when you are:-

1).Using many different reports in which to pull your page numbers from.
2).Your page numbers are frequently changing as the content of the data changes within each report.

If anyone has any suggestions please could you give us a shout ASAP

Many Thanks


Would anyone be interested in Table of Contents for reports, with the number of the pages? I have create a VBA module and some table to give you a truly
Table of contents. So you can combine multiple reports into a book with the correct page number. I want to get some feedback to see if it worth to pull that function out of a production application.

In Access 2007:

I'm hoping someone already has a technique for generating a table of contents for database documenter output.

So far I've gotten the documenter output in Word and can format a portion of the page heading to be marked for a table of contents. [Replace all Page: # with nothing, replace "Query:" with formatted "Query:", etc.] When the TOC is generated there are duplicates for those objects occupying more than one page. It would be nice to only generate the TOC with unique headings.

Or is this an opportunity to teach myself some VBA for Word?



I have a very large report ( more than 1000 pages) with picture of about 7000 items it . The items are all seperated into categories( about 100 categories)

I have written a seperate report to generate a table of contents

both reports work well, but i am sick of joining the two pdf files( once the print out) . I would like to join them in the one report

I would like to concatinate ( join together)the two reports in the one report, the 1000 pages of data and the table of contents

preferable the TOC first and then the main report with pictures...but lets crawl before run....the report then the footer is good enough

The only way i can see to do this is to put a subreport into the report footer.....
The problem is they are unrelated reports and i cant get it to display anything except the page number of the last category by doing this

Is it possible to put a subreport in a report footer?

any ideas?

any help would be greatly appreciated......

ps using access 2003

Hello everyone!

I'm building a report with 5 subreports in it. Each of the 5 subreports is divided by a page break in between. The reason for using these subreports is that I have to include a lot of graphs in the report, and each of the subreports is based on different tables.

Now, I'm also going to need a table of contents. I've been reading up on the subject, and most of the forum posts and how-to guides gives more or less the same version as the KB131588 article.

Is it possible to build a static table of contents using text labels and a VBA code that can track the page numbers of either a subform or a textbox?


Hi all,

I have created a report that extracts and groups data from a single table. This report groups the different categories (its an Emergency Plan, so there are categories such as "Police Departments", "Fire Departments", etc).

My question is - I want to create another report that will display a table of contents for this report. I want it to show each category and the page that it starts on. Is there some way to do this?


- Ryan

Access 20007:

I have a report that shows (among other things):
Category Detail

This report also counts the number of each items in each category with the category footer of =Count(*)

I then have a table of contents report that shows:
Description Page Number
The description changes each time the category changes.

I would like to change the table of contents report so that the count would appear next to each category. This would look like this:
Description Page Number Number of Entries

The code from the table of contents module is:

Option Compare Database
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.

Set DB = CurrentDb()

DB.Execute "DELETE * FROM tblTableOfContents;"

' Opens the table.
Set toctable = DB.OpenRecordset("tblTableOfContents", dbOpenTable)
toctable.Index = "Description"

End Function

Function UpdateToc(tocentry 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.

toctable.Seek "=", tocentry

If toctable.NoMatch Then
toctable!Description = tocentry
toctable![page number] = Rpt.Page
End If

End Function

What do I need to do ???

I have a report on my MS Access application which I would like to create a Table Of Content for. The problem is that MS Access cant do this automatically.

The solution I'm working with now is to create a table that stores the Headings and Page numbers when a Header is printed in the report. This works fine but the problem is that I have to scroll through my detailed rapport to store all the Heading page numbers in my t_TOC table.

The length of my detailed rapport vary a lot and it is not a good solution to let the user scroll through this rapport and then generate a TOC and finally print them out separately.

Is there a way to open the report in VBA (DoCmd.OpenReport "Report", acViewPreview)

And then run to the last page? .. or do any of you have any other solutions?

I want my main report to look like this:

- Cover Page [Main Report]
- Table Of Contents [Subreport]
- Details (vary from 13-230 pages) [Subreport]

Dear experts,
I am returning to the Forum after a long gap.
Is it possible to create a 'Table of Content' in Access Report as we do in Word Document?

Hey guys! Been a while, I know! I have a peculiar need. What I am wanting is to be able to build dynamic form content/elements based on entries on a table. This is for a gym membership system. What this form is going to be used for is to allow the front desk to scan a membership card which then performs a search on the database. Part of this search is going to be on a table that contains various add-on classes, tanning sessions, etc that a member can add beyond their base membership.

On the left side of the form, I will display a picture of the member and their name. What I am wanting to do on the right side of the form is to build a dynamic list of the add-on perks they are enrolled in.

I know I could hard program elements on the form to be visible or invisible, but that would be static and leave gaps when I have to turn things off b/c that member isn't enrolled in that class, etc.

Is this even possible with Access and VBA? I know I could do this sort of thing with a webpage using PHP, PERL or whatever. I don't know the limits of Access Forms and VBA.

I have a TOC, manually created, which is currently a sub-report to my main report.

I've read the MS Knowledge Base instructions for creating an automatic TOC, and I'm thinking of trying them.

The instructions indicate that when you print or preview the report, the TOC is generated, and then you print the TOC separately to the main report. I'm wondering if I could set a code, which instead of directly printing the report would a) preview the report and therefore generate the TOC sub-report; then b) refresh the report, to update the TOC sub-report in the main report; then c) print. I'm thinking that to the end user this should just look like a printing function.

My other thought would be to have a separate code button that says "generate TOC", which previews, updates the sub-report, (which would update the main report). And then the actual printing is a separate command.

Any thoughts? Comments? Previous experience?

Just working through these instructions the MSKB. Step 4 - "Create the following procedure". What does this mean? I've only ever written code by going through the event tab of the properties of an element. Where do I put this code?

Frizzle frazzle. These instructions aren't going to work for me 'cause my 'headings' are labels. They're not fields in a table anywhere. My basic report layout is:

Label with heading

repeated about 14 times.

Any further thoughts?


Does any of you know how to make it possible to edit the fields of a form displayed as a dynamic table? If the form is displayed as a data sheet the records can be edited but when the form is displayed as a dynamic table the records CANNOT be edited. Basically I would like to have the funcionalitty of a dynamic table as if it was displayed in a html page.

Thanks in advance for any help.




Does any of you know how to make it possible to edit the fields of a form displayed as a dynamic table? If the form is displayed as a data sheet the records can be edited but when the form is displayed as a dynamic table the records CANNOT be edited. Basically I would like to have the funcionalitty of a dynamic table as if it was displayed in a data access page.

Thanks in advance for any help.



I've been working on this problem for quite a while now, so any insight that anyone can offer will be gladly received.
I've looked through at most of the posts with a similar vein in them, but none seem to really address what I'm looking for.

I have a main report. In the first section is the page header.
The second section has the section header and an unbound sub-report that will contain the data that corresponds to it.
In print-preview terms, for each section header there will be a different sub-report.

I've been working on adapting the standard TOC module, so I have a "Table of Contents" table, within which are: "Section", "Description", and "Associated Table".
I haven't got my TOC module working yet, but once this bit gets rolling it shouldn't be a problem.

So, in the page layout we would have:

Page Header
Section Header (values taken from "Table of Contents")
SubForm (bound to a different form on each page)

I've tried doing this in the report's onOpen, and in the applicable sub-report's events - I generally get the same error about not being able to change the record-source once printing has began.

I would like to keep it in this sort of style if a little hack-around could be found because I want to be able to use the TOC module along with it (and this way would probably make it really easy), but as I'm still coming up with nothing if anyone else can think of an alternative solution it would really make my day.

Thanks in advance for any replies.

As usual, something which I thought would be pretty straightforward is proving more difficult than anticipated. Done the usual searches and surprisingly couldn't find an answer.

I have a main-report (rptMain) which has, say, 4 subreports (rptSub1, rptSub2 etc)

How can I return the number of the page of the main-report that each subreport starts on?

I'm doing this to create a basic Table of Contents (if I know where each subreport starts, I can use that page number as the start of a section in the TOC). I've seen the MSKB article on TOC's but it doesn't seem to fit what I want (my real situation is more complicated than that described above)

here's hoping....

I need to add "dots" between columns in a report so that a line in the report might look like:

Queen............................................. ...Elizabeth II

What I cannot figure out how to do is add the string of periods between the two columns. The fields involved would be POSITION and NAME and would have both positions and names of varying lengths.

Any ideas?


I used to work with Access a lot, but it was a long time ago, and I'm having a hard time working out how to do what should be a fairly simple task.

I want to create a report, with a similar structure to this:

Intro Page
Table of contents
table 1, 1 record per page (along with single field list of related records from table 2)
table 2, 1 record per page

I've grown so used to scripting, that my instinct is just to use VBA to query the tables and build the reports programatically, which makes perfect sense to me, and since the records from the tables are one per page, so long as I can calculate the length of my TOC, it should be a fairly trivial matter.

However, my problem is that apparently you can't add controls to a report programatically.

The next thing I thought to try was using subreports. Problem is, page breaks on subreports are ignored, so I can't force the one record per page rule, which is a requirement. So this method isn't a great deal of use to me.

The final thing I thought to try was a UNION query, but one table has 10 fields, and one has 44. While I can just pad out the smaller table with dummy expressions, it seems messy, plus that's a lot of controls to work out how to rearrange and hide. It just doesn't seem like a practical solution.

Is there a sensible way to do this, or am I going to have to look to a third party reporting solution?

Thanks for any help,


Perhaps this isn't the most appropriate method of verifying user identity, as someone could use an existing login on some server, or login with someone elses password, but I believe that shouldn't be an issue to deal with here. I've spent the past 8 hours poring over the boards, and can't quite find this particular scenario on the boards. It seems that either a Dcount, or a DLookup would be the most likely avenues to take, but I am unable to get an accurate result from my If Statements.

I've got my DB to query a current users login to the system, and would like to make some buttons visible for all users, and some buttons useable to just a specified list of users. If I hard-code the users names into the VBA codes for each action I am successful, but when I attempt to compare the textbox on the form to a table of allowable users I get a result that seems to be completely ignoring my if statement and showing everything to everyone. This is the function that is causing the problems:

	Private Sub Form_Open(Cancel As Integer)
On Error GoTo Exit_Form_Open_Click

With DoCmd
    .Hourglass True
    .SetWarnings False
    .OpenQuery "qry Mar Geology Data"
    .OpenQuery "qry Apr Geology Data"
    .OpenQuery "qry Graphing Query"
      'These are update queries that I am currently running because my data
      'relies on some Excel sheets from another department that I import for
      'calculation purposes.
    .SetWarnings True
    .Hourglass False
End With

If DLookup("[Allowed Usernames]", "tbl Database Admins", "[Allowed Usernames] = " & [UserNameControl]) Then
     ' I have also tried various punctuation options based on examples on the
     'boards. The [Allowed Usernames] is the field with usernames in the table
     'called "tbl Database Admins", and [UserNameControl] is the textbox on
     'this form, which is generated via a module that queries the windows
     'username, in my case that is  which matches an entry in tbl
   Me.Modify_Budget.Visible = True
   Me.Modify_Forecast.Visible = True
   Me.Modify_Calculation_Factors.Visible = True
   Me.Daily_Data_Entry.Visible = True
   Me.Email_Report.Visible = True
   Me.Email_Report_Text.Visible = True
   Me.Modify_Email_List.Visible = True
   Me.Database_Admin_List.Visible = True
    Me.Modify_Budget.Visible = False
    Me.Modify_Forecast.Visible = False
    Me.Modify_Calculation_Factors.Visible = False
    Me.Daily_Data_Entry.Visible = False
    Me.Email_Report.Visible = False
    Me.Email_Report_Text.Visible = False
    Me.Modify_Email_List.Visible = False
    Me.Database_Admin_List.Visible = False
End If

    DoCmd.SetWarnings True
    DoCmd.Hourglass False
    Exit Sub

End Sub

I have attempted some error trapping within both if options, but the msgbox's that I put in did not appear at any point. It seems as if the condition of the if statement is as far as it goes, and the form will open with all options visible no matter who logs in, whether they are in the database admin list or not.

Hi, can someone please give me some inspiration on this?

I need a piece of VBA that will generate a table of all weekend dates for a particular calendar year.



I want to have a table of 'database defaults' in my DB
each of the defaults is a setting that applies to all of the DB

how do i relate this table to the rest of the relationships or more simply how can i pull in one of these default settings into a calculation?

Example: I am trying to generate a warranty expiry date on a 'field exit' event.

the default warranty period in 'months' is contained within 'tblDatabaseDefaults' under the 'WarrantyPeriod' field

	Dim intWarrantyIncrement as integer

intWarrantyIncrement = ??? (tblDatabaseDefaults - WarrantyPeriod)

I think I may just be being thick!!!

can anyone help ??

Not finding an answer? Try a Google search.