Results 1 to 12 of 12
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    TOC for report (XP/2K)

    I wuold rather not reinvent the wheel (it would probably come out a triangle). Is there some code that will get the Group headers and page numbers and create a TOC for a report?
    Thanks

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: TOC for report (XP/2K)

    Excuse my ignorance, but what's a TOC?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TOC for report (XP/2K)

    Take a look at ACC2000: How to Create a Table of Contents or Index for a Report. This MSKB article describes a way to create a table of contents for a report, and a link to download the Sample Reports database with an example of this technique.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    Sorry Pat. I assume you figured it out from Hans's answer.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: TOC for report (XP/2K)

    What Hans has suggested is one way to do it.

    I have been accumulating stats for horses over a couple of years now and have developed a report that shows by month how the horses are running. It has a group header and footer for a change of month.
    This was tedious to go thru quickly to analyse by month, so I setup a checkbox on the form I called the report from, this checkbox signalled whether the report was a summary report or a full detail report. If a summary (which is effectively a TOC) was required then I would set the Detail section to invisible as well as the Group Header.
    I would end up with a one liner per month which would give me totals of how the horses were running.

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    Thanks for the link (http://support.microsoft.com/?kbid=210269).
    I am trying to use it, and the code hangs on the creation of the index in function initdoc.

    at this point in the code

    'Open the table.
    Set TocTable = db.OpenRecordset("Table Of Contents", dbOpenTable)

    TocTable.Index = "Description"


    I get error 3800 "description is not an index in this table". The line before is opening the DAO recordset, that I checked by putting in a debug.print that gives TocTable.Fields(0).name. I even have the name of the field spelled correctly.
    Any idea what is wrong?
    Thanks

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TOC for report (XP/2K)

    For this to work, you must have done the following:
    <UL><LI>Create a table named "Table of Contents"
    <LI>Create fields in this table named "Description" (text) and "Page Number" (or something similar, numeric).
    <LI>Set an index on Description.[/list]If you haven't set an index on Description, you should do it now.

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    The index is set in the table. I still get the error. Any other ideas?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TOC for report (XP/2K)

    I don't understand. There must be some difference between your setup and the one described in the MSKB article. I tested it and it works fine.

    As a workaround, try the following:

    1. Change the line in InitToc that opens the recordset to<pre>Set TocTable = db.OpenRecordset("Table Of Contents", dbOpenDynaset)</pre>

    and remove or comment out the offending line setting the index.

    2. Change the line TocTable.Seek "=", TocEntry in UpdateToc to<pre>TocTable.FindFirst "Description = '" & TocEntry & "'"</pre>

    HTH

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    That works.
    Thanks Hans once again

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    dbOpenTable and Seek apply to local tables. If you were trying to use them against an attached table, that was the problem. The second code Hans posted will work with either local or attached tables.
    Charlotte

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: TOC for report (XP/2K)

    Thanks for the info. That was the issue.
    I have not had a chance yet, but there is one update I would like to make to this code. IF a heading covers 2 or more pages then in the TOC it is repeated once for each page that its detail section is on.
    The easy way to fix this is: on the report that is based on the TOC table to set the value of the heading text box to not show duplicates. IT still shows though each page number. I assume I can figure a way that it will only show each heading once for the FIRST page that it appears on. Hopefully tomorrow.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •