Results 1 to 8 of 8
  1. #1
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875

    Recursive Report!

    Hey all! Just a bit ago I figured out how to "tier" Records in a Table so that the Table knows that certain Records are "children" of another Record. Basically, you just reference the ID of the immediate parent Record in the same table.



    Code:
    RecordID|ParentID|Description
    1|0|Parent Record
    2|1|Child Record 1
    3|1|Child Record 2
    4|2|Sub-child Record 1.1
    5|2|Sub-child Record 1.2
    6|3|Sub-child Record 2.1
    7|3|Sub-child Record 2.2
    8|3|Sub-child Record 2.3
    9|7|Sub-sub-child Record 2.2.1
    So now I have a new problem: displaying that data in a Report!

    Basically, I want to "tab in" child records, like so:

    • Parent Record
      • Child Record 1
        • Sub-child Record 1.1
        • Sub-child Record 1.2

      • Child Record 2
        • Sub-child Record 2.1
        • Sub-child Record 2.2
          • Sub-sub-child 2.2.1

        • Sub-child Record 2.3



    Is there a way to do this when I don't know how many levels deep the Records go?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Perhaps this link will suggest some ideas: http://allenbrowne.com/ser-59.html

  3. #3
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    If I understand the code, all this does is provide you with an array (ok, a linked list/collection) representing the full parent/child relationship between records.

    While I'll definitely need to do something like this to collect the data, it still doesn't seem to help me display it in a Report.

    I went through the code pretty fast though, maybe I missed something?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    There is no native procedure to recurse through a table that could be n levels deep. You would have to code it yourself of maybe use a method to fill a table with your values after recursion.

  5. #5
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Ah, gotcha.

    Is there a method to generate a Report based entirely on VB code and without any actual Table/Query? Or would I need to find a way to dump the collection into a dynamically generated Table?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would say this is a case for using a temporary table. I put my temporary tables in a separate dynamically created backEnd and delete the BE when done. It avoids the bloat.

  7. #7
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Oooo, that's a good idea!

    I'll look into doing it that way then. If I run into any problems, I'll post back here

    Thanks!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Good luck and have fun.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recursive Tables!
    By Rawb in forum Database Design
    Replies: 1
    Last Post: 01-26-2011, 02:46 PM
  2. Replies: 4
    Last Post: 12-13-2010, 05:33 PM
  3. Replies: 2
    Last Post: 08-25-2010, 01:42 PM
  4. Replies: 3
    Last Post: 05-21-2010, 03:57 PM
  5. Recursive Lookup and display?
    By madyson in forum Access
    Replies: 3
    Last Post: 12-15-2009, 09:01 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