用于创建缩进材料清单的递归代码 [英] Recursive code to create indented bill of material

查看:61
本文介绍了用于创建缩进材料清单的递归代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2张表,一对多,包含物料清单(BOM):


tblBOM:

lngBOMID(PK)< br $>
strAssemblyPartNo

strDescription


tblBOMDetail:

lngBOMDetailID(PK)

lngBOMID(FK)

strPartNo

strDescription

intQuantity


物料清单包含单个零件和其他组件。我需要在分层列表中列出

零件和装配及其各自的零件。我想要在VBA w / DAO或ADO中递归地执行此操作。


我已经搜索了一段时间但仍未找到解决方案确切地说

我在寻找什么。我以为我会创建一个部件列表,其中包含缩进级别,并从那里创建报告。


我真正坚持的是创建递归例程。可以有人

请让我开始。


提前致谢。

解决方案

< blockquote> Gary,

我写了一个并且遇到了填充调用堆栈的问题,之前我已经在我的层次结构中最大化了我的级别。一个很酷的方法是

确定树的深度,然后构建一个包含尽可能多列的表格。

树中有级别。 *大多数*树的大小往往在3到7之间,这意味着大多数层次结构都可以映射到包含7列的表中。

无论如何,构建报告意味着迭代

这一列的起始点。举个例子,让我们说CD珠宝盒

是成品商品Virtual PC的一部分。珠宝盒位于层次结构的底部附近,因为它由四个组件组成,并且包含

CD,它位于层次结构的底部。珠宝盒进入一个

的内部盒子,将其固定在外盒中。无论如何,

我的数量我们有四个级别意味着我们需要四个colums来映射每个

组合的CD,珠宝盒&框。在我的

示例中,Virtual PC是#vpc_42005的一部分。所以,我发现第一列中有我的部件号和

的行然后遍历我的列以查找组件部分。完成,并且不需要

递归。

-

Alan Webb
kn ******* @ SPAMhotmail.com

这不是IT,它是IS


" Gary Manigian" < GA *** @ designconcepts.net>在留言中写道

news:30 **************** @ fe10.lga ...

我有2张桌子,一对多,包含物料清单(BOM):

tblBOM:
lngBOMID(PK)
strAssemblyPartNo
strDescription
tblBOMDetail:
lngBOMDetailID(PK)
lngBOMID(FK)
strPartNo
strDescription
intQuantity

BOM包含单个零件和其他装配。我需要在零件列表中列出零件和装配及其各自的零件。我希望在VBA w / DAO或ADO中递归地执行此操作。

我已经搜索了一段时间的解决方案但是没有找到
我正在寻找的内容。我想我会创建一个包含缩进级别的部件列表,然后从那里创建报告。

我真正坚持的是创建递归例程。可以有人
请让我开始。

提前致谢。



阅读这些,,, http://www.mvps.org/access/queries/qry0023 .htm
http:// www。 mvps.org/access/modules/mdl0027.htm


阅读这些,,,
http://www.mvps.org/access/queries/qry0023.htm
http://www.mvps.org/access/modules/ mdl0027.htm


如果你真的想要一个脑筋急转弯,请阅读Joe Celko的'SQL for

Smarties'。不是一个聪明的人,我想我不合格...


I have 2 tables, one-to-many, that contain bills of material(BOMs):

tblBOM:
lngBOMID (PK)
strAssemblyPartNo
strDescription

tblBOMDetail:
lngBOMDetailID (PK)
lngBOMID (FK)
strPartNo
strDescription
intQuantity

The BOMs contains individual parts and other assemblies. I need to list the
parts and assemblies with their respective parts in a hierarchical list. I
want to do this recursively in VBA w/ DAO or ADO.

I have searched around for a solution for a while but haven''t found exactly
what I an looking for. I thought I would create a list of parts that
contained the indent level and from there create the report.

What I am really stuck on is creating the recursive routine. Can someone
please get me started.

Thanks in advance.

解决方案

Gary,
I wrote one and ran into problems with filling the call stack before I had
maxed out my levels on my hierarchy. The one cool way around this is to
identify how deep the tree is and then build a table with as many columns as
there are levels in the tree. *Most* trees tend to be between 3 and 7
levels meaning most hierarchies could be mapped in a table with 7 columns.
Anyway, building your report would mean iterating through the columns of
this table from a beginning point. As an example, let''s say CD jewel cases
are part of the finished good, Virtual PC. The jewel case is near the
bottom of the hierarchy because it consists of four components and contains
a CD, which is at the bottom of the hierarchy. The jewel case goes into an
interior box that holds it in place which goes into an outer box. Anyway,
by my count we''ve got four levels meaning we need four colums to map every
combination of CD, jewel case & boxes. Virtual PC is part #vpc_42005 in my
example. So, I find the row in the first column that has my part number and
then loop through my columns to find component parts. Done, and no
recursion needed.
--
Alan Webb
kn*******@SPAMhotmail.com
"It''s not IT, it''s IS"

"Gary Manigian" <ga***@designconcepts.net> wrote in message
news:30****************@fe10.lga...

I have 2 tables, one-to-many, that contain bills of material(BOMs):

tblBOM:
lngBOMID (PK)
strAssemblyPartNo
strDescription

tblBOMDetail:
lngBOMDetailID (PK)
lngBOMID (FK)
strPartNo
strDescription
intQuantity

The BOMs contains individual parts and other assemblies. I need to list
the parts and assemblies with their respective parts in a hierarchical
list. I want to do this recursively in VBA w/ DAO or ADO.

I have searched around for a solution for a while but haven''t found
exactly what I an looking for. I thought I would create a list of parts
that contained the indent level and from there create the report.

What I am really stuck on is creating the recursive routine. Can someone
please get me started.

Thanks in advance.



read these,,,
http://www.mvps.org/access/queries/qry0023.htm
http://www.mvps.org/access/modules/mdl0027.htm


read these,,,
http://www.mvps.org/access/queries/qry0023.htm
http://www.mvps.org/access/modules/mdl0027.htm

and if you really want a brain teaser, read Joe Celko''s "SQL for
Smarties". Not being a smarty, I guess I''m not qualified...


这篇关于用于创建缩进材料清单的递归代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆