Looping function

T

TCF

I have a file of a bill of material that I want to loop through and add the
upper level part number to the respective level. Here is what I start with.
The end result will be a bill of material files showing which parts go into
which upper levels.

level P/N
0 Part0
1 Part1
2 Part2
3 Part3
3 Part4
0 Part5
1 Part6

The results desired would look like this

level P/N ParentPN
0 Part0
1 Part1 Part0
2 Part2 Part1
3 Part3 Part2
3 Part4 Part2
2 Part5 Part1
1 Part6 Part0

I hope this is clear.
thanks
 
R

Rich K

TCF,
How do you know that Part1's parent is Part0 and not Part5?
Similarly, Part2's parent is Part1 or Part6?

It seems to me some information is missing. Perhaps a field that contains
the foreign key to the parent. This foreign key can point to the key in the
same table.

You can create the loop, but the logic for determining which is the parent
key will have to be supplied, or you can just select them individually.

Hope this helps.
 
J

John W. Vinson

I have a file of a bill of material that I want to loop through and add the
upper level part number to the respective level.

If you're assuming that the order of records in the table is constant, you're
mistaken. There is no "looping" in Access queries; you need some information
*in each record* to indicate which other record is its parent.

John W. Vinson [MVP]
 

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