我使用Access 2003 VBA處理製造BOM的遞歸數據。我建立了一個類模塊,讓我的主表具有靜態範圍。這似乎簡化了遞歸 - 當我遍歷BOM時,它使我無需再次計數級別。我不是多餘地打開相同的記錄集;我正在過濾很多。正確使用類實例
在得到這個進展之後,我讀了關於對象關係建模並決定實例化一個記錄集,而不是一個記錄。然後該記錄的字段可以是屬性。經過大量工作和大部分錯誤的勝利刺激後,我意識到這種方法沒有好處,因爲Access基於表格。
我的課程模塊仍然像以前一樣幫助。我的問題是關於以下兩個替代版本。第一個使用兩個實例(Parent,Child)。第二個使用一個然後重新使用它。顯然,第一個是受ORM影響的。
是否有任何理由選擇其中之一?另外,最後注意斜體行:如果我不需要(因爲我不需要關於父母的更多信息),這是否會改變答案?任何人都可以用我的想法來幫助我嗎? (注意,我關閉了記錄集,但沒有類實例,我的理解是VBA實例關閉它們並讓它們這樣做是可以接受的做法,我似乎已經將僞代碼提升到了新的僞目標層次......目標爲清晰起見,希望它的工作原理。)
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_IDCreate instance of Class --> Get recordsetFilter 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)
我很感謝回覆(7/19之一)。但我的無知並沒有感覺到有所改善。我正在按「接受」按鈕,希望我會在一天中瞭解如何提出問題。 – Smandoli 2009-07-20 21:30:16
您是否檢查了在查詢Google Groups以獲取「BOM類模塊組:* access *」時所獲得的少量線程?這個話題是Access組中常年出現的,儘管並不總是用類模塊來解決(儘管它對我來說應該是合乎邏輯的)。 – 2009-08-08 00:15:03