Bill of Material Processor

D

dcsteps

I am writing a simple Bill of Material processor supporting multi-level bills
using Visual Basic. I need a quick way to ensure that any given part is not
used on itself at any level above the level currently being entered?

I am trying to avoid testing each where used string as this can become very
complicated. Any suggestions?
 
D

dcsteps

Allen:

Appreciate the response. Each component is entered into a single
relationship record containing the parent and the child. As can be seen, an
item may be a parent at one level and a component for numerous parents at
numerous levels. It would require a reiterative query for an unknown number
of cyles.

David S.
 
A

Allen Browne

Sorry, David, I did not read your question clearly.

Yes, the solution will involve iterating through the parents recursively
until you reach the top of the tree. There are two ways to do that. One is
with a VBA function. It's not too difficult to write recursive code, but the
practical issue is the endless loop if a subassembly is in its own parent
line. To avoid that means keeping a trace (probably an array) of the p.k.
values, and checking that you have not already visited the same record in
this tree.

Actually, whenever I've had to do these, I've cheated. I specify a limit on
the number of levels deep that are permitted, and then create an temp table
that resolves each child and each parent/grandparent/great... so you can see
each ancestor of a part. This unnormalized table gives instant performance,
which is certainly not the case if you are constantly opening recordsets and
tracing levels.

The other approach is to try to do this in SQL. I started some research on
this years ago, but never actually followed a solution through as it looked
messy. Joe Celko's stuff sounded promising if you wanted to chase that
approach. Links:
http://www.intelligententerprise.com/001020/celko.shtml
http://www.dbmsmag.com/9603d06.html
http://www.dbmsmag.com/9604d06.html
http://www.dbmsmag.com/9605d06.html
http://www.dbmsmag.com/9606d06.html

HTH
 
D

dcsteps

Allen:

Thanks for your feedback. I will probably need to assign low level codes to
know when I've reached the top.

David S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top