Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 46
  1. #16
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Changed the line to what microsoft has and still the same error... Doesn't seem to understand where the inittoc is.
    Yes Case_Name is a field instead of description.

    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 * 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

  2. #17
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    How did you set up OnOpen and OnPrint properties now?
    As MS suggested ("=InitToc" as property) or as you tried before but without equal sign?

  3. #18
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Here is what I have ..Won't let me use the = sign for Init

    Click image for larger version. 

Name:	Capture_1.JPG 
Views:	14 
Size:	32.6 KB 
ID:	23633Click image for larger version. 

Name:	Capture_2.JPG 
Views:	14 
Size:	35.9 KB 
ID:	23634

  4. #19
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    It needs to be
    =InitToc()
    here to make it work.
    Also make sure you removed that previous attempt from report module (as you tried in post #10).

  5. #20
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    I can't use the = sign as it gives me a syntax error
    Click image for larger version. 

Name:	Capture.JPG 
Views:	14 
Size:	52.2 KB 
ID:	23635

  6. #21
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    I don't know why then. It must work that way and it works for me. Can you upload your db?

  7. #22
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    I have had to get rid of the data and put some fake stuff in. But here it is.

    Testing_Litigation_DB1.zip

  8. #23
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Ok.
    Actually there's few things you didn't follow from the website you linked:
    1. Dim toctable As Recordset in your code became Dim toctable As Table (???), that's where compile error came from.
    2. You were supposed to create table "Table of Contents" (and that's how you refer to it in code), but your table is named "Table1"
    3. Set toctable = db.OpenRecordset("Table of Contents", DB_OPEN_TABLE) in your code became Set toctable = db.OpenTable("Table of Contents") -again reason for compile error and table name not in pair with what you created
    3. You changed name of the "Description" field to "Case_Name" and that's fine, but it needs to be indexed to work.
    4. After you fix all of this you will be able to set OnOpen property to =InitToc() and all will work from there.

  9. #24
    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:	14 
Size:	21.0 KB 
ID:	23637OK, so close now. What do you mean by the index? I get an index error now. When opening the report.

  10. #25
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    From the website you linked:

    Create the following table and save it as Table Of Contents: Table: Table Of Contents
    -------------------------------
    Field Name: Description
    Data Type: Text
    Field Size: 15
    Indexed: Yes (No Duplicates)
    Field Name: Page Number
    Data Type: Number
    Field Size: Long Integer
    Indexed: No

  11. #26
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Ignore that last one. Figured out the index myself...


    NOw a stupid question....How do I get the tables to be propagated with the data I need?

  12. #27
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Yeah I made sure all that matches except for long Integer as I see no option for that. Still nothing shows in the table.

    Sorry, so new at this. Where is it pulling this data from? How does it know what the field Description is?
    I need it to pull the case name and then give it a page number. Just not sure where in the code it does this.

  13. #28
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Again, if you'd followed MS instructions to the letter there wouldn't be any problem
    Where is it pulling this data from?
    It pulls data from report from which you want TOC to be created. Descriptions and page numbers are store in the table "Table of Contents" and then another report based on that table is created. There's couple of thing you should take care of (as per MS instructions):
    NOTE: Make sure the Description field is the same data type as the field on your report that you will use as a table of content heading.
    Meaning that, if you want Case_Name to be your TOC description field then both Case_Name and Description fields must be of the same type/size.
    ' Call from the OnPrint property of the section containing
    ' the Table Of Contents Description field. Updates the Table Of
    ' Contents table.
    You need to call this function from OnPrint property of Case_Name section of report. Which you need to create first using report Group & Sort feature. And that's how it knows what Description is.
    Of course I could make it all for you, but what's the point really? That way you still won't understand what's happening and why and you won't be able to fix smallest bugs. So I suggest to go through MS instructions again with the knowledge you already have, follow it to the letter and customize it to your needs (like case_name for example).


  14. #29
    pharrison74 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    114
    Ok I will give that a go. Will update later if successful or not.

  15. #30
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Please do. And if not successful, we'll try to make it so

Page 2 of 4 FirstFirst 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