我正在使用Access 2003 VBA处理制造BOM的递归数据。我构建了一个类模块,让我的主表具有静态作用域。这似乎简化了递归——它让我在遍历BOM时免于反复计算级别。我不会冗余地打开同一个记录集;我过滤了很多。
在开始这项工作后,我阅读了《对象关系建模》,并决定不实例化记录集,而是实例化记录。然后,该记录的字段可以是属性。经过大量的工作和许多胜利的刺激,我意识到这种方法没有任何好处,因为Access是基于表的。
有什么理由选择其中一个而不是另一个吗?此外,请注意末尾的斜体行:如果我不需要(因为我不需要更多关于父级的信息),这会改变答案吗?有人能帮我思考一下吗?
VERSION 1
Property Sub ReviewPart ( Parent_Part_ID )
Get Parent_Part_ID
Create instance of Class --> Get recordset
Filter Class recordset ( Parent_Part_ID )
Exploit Class recordset
See if Parent_Part_ID has Childs
If it does:
Open recordset of Childs
For each Child
Get Child_Part_ID
Create instance of Class --> Get recordset
Filter Class recordset ( Child_Part_ID )
Exploit Class recordset
See if Child_Part_ID has Childs
If it does:
Instance New ReviewPart ( Child_Part_ID )
Otherwise:
Nothing; Move On
Next Child
Close recordset of Childs
Otherwise:
Move On
Exploit Class recordset ( still points to parent )
VERSION 2
Property Sub ReviewPart ( Parent_Part_ID )
Get Parent_Part_ID
Create instance of Class --> Get recordset
Filter Class recordset ( Parent_Part_ID )
Exploit Class recordset
See if Parent_Part_ID has Childs
If it does:
Open recordset of Childs
For each Child
Get Child_Part_ID
Create instance of Class --> Get recordset
Filter Class recordset ( Child_Part_ID )
Exploit Class recordset
See if Child_Part_ID has Childs
If it does:
Instance New ReviewPart ( Child_Part_ID )
Otherwise:
Nothing; Move On
Next Child
Close recordset of Childs
Otherwise:
Move On
Filter Class recordset ( Parent_Part_ID )
Exploit Class recordset ( still points to parent )