paoconnell
Programmer
I need to print a report of the structure of a multiway tree of nodes, stored as two tables in an Access 2000 database. The master table contains node information. The other table stores connections between nodes that have inputs and their inputs.
Fortunately, a simple way to print the structure is as an outline, with the top record at the left, and its input records printed below it. Judging from a quick browse of this group, recursion is in general OK in Access VBA
The simplest way to do this is a recursive function, called the first time with a record and an indent level, using FileSystemObject to print each line of the outline, with recursive calls to the function for each of the input nodes associated with the input node, at an incremented indent level. A record with no inputs simply prints and exits without additional calls to the function.
Unfortunately, this strategy means that each call to a node with (say) 4 inputs will generate four recursive calls to the function, each of which will have a local recordset. I'm wondering about stack overflow, here...
The alternative is to iterate carefully through the tree, using a stack object to simulate recursion. I've done this before on a tree in another project, but it's messy.
Has anyone out there done something similar? Is recursion in Access 2000 "safe" to use, or is the report likely to run out of stack space (the tree is wide, but only 4 deep at this point).
Thanks!
Pat O'Connell
Fortunately, a simple way to print the structure is as an outline, with the top record at the left, and its input records printed below it. Judging from a quick browse of this group, recursion is in general OK in Access VBA
The simplest way to do this is a recursive function, called the first time with a record and an indent level, using FileSystemObject to print each line of the outline, with recursive calls to the function for each of the input nodes associated with the input node, at an incremented indent level. A record with no inputs simply prints and exits without additional calls to the function.
Unfortunately, this strategy means that each call to a node with (say) 4 inputs will generate four recursive calls to the function, each of which will have a local recordset. I'm wondering about stack overflow, here...
The alternative is to iterate carefully through the tree, using a stack object to simulate recursion. I've done this before on a tree in another project, but it's messy.
Has anyone out there done something similar? Is recursion in Access 2000 "safe" to use, or is the report likely to run out of stack space (the tree is wide, but only 4 deep at this point).
Thanks!
Pat O'Connell