Page 1 of 4 1234 LastLast
Results 1 to 15 of 46
  1. #1
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114

    Creating a Table of Contents

    I found an article which explains it however I am having a tough time understanding it fully.
    I created the table and the module they asked for . However when trying to create a procedure I am lost.


    Doesn't explain where to put this code.

    Link is below.

    Thanks

    Peter

    https://support.microsoft.com/en-us/kb/131588

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you make a table called TOC,
    empty it (delete query)
    then scan thru all queries/tables and write the table.Descrption (as an append query) using VB code.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The procedures in 4 would go in the module just created. Don't name the module the same as any of the procedures.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    You have to put functions InitToc and UpdateToc in module you created and then set OnPrint and OnOpen properties to relevant functions (5. and 6. on the website you linked).

  5. #5
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Thanks for the replies, however I am completely lost.
    I created the table as per the article, then in that table put the following in a module with in that table
    Option Explicit
    Dim db As Database
    Dim toctable As Table


    Then it tells me to create a procedure but I have no clue where to do that? Am I creating a report now off of the table?

  6. #6
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    I think you have it mixed up a bit.
    Steps on the website are:
    1. open database
    2. create table "Table of Contents"
    3. create a module and put some code in declarations section (top of the module)
    4. in the same module below create functions (procedures) as stated
    5. in report's design view set up OnOpen property
    6. in report design view again set report's header's OnPrint property
    7. create another report based on the table created in step 2

  7. #7
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Ok will see what I can do.

    Thanks
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  8. #8
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Ok got to 6 and getting an error.

    Attachment 23621

  9. #9
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Your attachment is not showing.

  10. #10
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Click image for larger version. 

Name:	Capture.JPG 
Views:	31 
Size:	32.4 KB 
ID:	23622

    See it?

  11. #11
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    I never created a TOC, but I guess they meant something like this:
    Click image for larger version. 

Name:	repopen.jpg 
Views:	31 
Size:	30.0 KB 
ID:	23623

  12. #12
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Get a compile error when I type it like that.

    Seems want something in the =InitToc() brackets?
    No where online can I find it needs something. Anyone got any ideas?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can have it in code the way you were trying, but without the equals sign. The method in post 11 should work, and is what the link described.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Click image for larger version. 

Name:	Capture.JPG 
Views:	24 
Size:	30.0 KB 
ID:	23631Here is what I get when I don't use the = sign...progress..
    I have the following code in a module
    Option Explicit
    Dim db As Database
    Dim toctable As Table
    Function InitToc()
    ' Called from the OnOpen property of the report.
    ' Opens the database and the table for the report.
    Dim qd As QueryDef
    Set db = CurrentDb()
    ' Delete all previous entries in the Table of Contents table.
    Set qd = db.CreateQueryDef("Delete TOC Entries", "Delete * _
    From [Table of Contents]")
    qd.Execute
    qd.Close
    ' Open the table.
    Set toctable = db.OpenTable("Table Of Contents")
    toctable.Index = "Case_Name"
    Exit Function
    End Function

    Function UpdateToc(tocentry As String, Rpt As Report)
    ' Call from the OnPrint property of the section containing
    ' the Table Of Contents Description field. Updates the Table Of
    ' Contents table.
    toctable.Seek "=", tocentry
    If toctable.NoMatch Then
    toctable.AddNew
    toctable!Case_Name = tocentry
    toctable![page number] = Rpt.Page
    toctable.Update
    End If
    End Function

  15. #15
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    That code doesn't look good when I just copied/pasted it in module:

    Click image for larger version. 

Name:	toc1.jpg 
Views:	24 
Size:	59.2 KB 
ID:	23632
    You need to correct that red line.
    Also, code on the website you linked before is slightly different.
    Is there [Case_Name] field in your "Table of Contents" table?

Page 1 of 4 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-16-2014, 04:20 PM
  2. Replies: 5
    Last Post: 04-05-2014, 08:52 PM
  3. Table of Contents
    By Alex Motilal in forum Reports
    Replies: 1
    Last Post: 09-17-2012, 10:48 AM
  4. Replies: 5
    Last Post: 04-18-2012, 12:04 PM
  5. Replies: 5
    Last Post: 12-08-2011, 10:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums