我继承了MS Access数据库,其宏通常会在其定义中重复调用相同的宏,即。 BOM Cost Sub-Macro
被召唤9次:
以这种方式构建宏的理由是什么?
宏的添加内容:
INSERT INTO [BOM Cost] ( [Top Level Item], [Level], [L1 Item], [L2 Item], [Mfg Process], Mold, Qty, [Sold Qty], [Earned Hrs], [Glass Wt], [Mat'l Cost], [Glass Frt], Resource, [Outside Processing], Overhead, [Rev Split] )
SELECT [BOM Build Item Table].[Top Level Item], [BOM Build Item Table]![Level]+1 AS [Level], BOM.Item, BOM.[Cost Item], BOM.[Mfg Process], BOM.Mold, ([BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS Qty, ([BOM Build Item Table]![Sold Qty]*[BOM]![Sold Qty]) AS [Sold Qty], ([BOM]![Earned Hrs/Mold]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS [Earned Hrs], ([BOM]![Mold Costed Wt]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS [Glass Wt], ([Item Level Incremental Costs]![Mat'l Cost]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS [Mat'l Cost], ([Item Level Incremental Costs]![Glass Frt]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS [Glass Frt], ([Item Level Incremental Costs]![Resource]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS Resource, ([Item Level Incremental Costs]![Outside Processing]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS [Outside Processing], ([Item Level Incremental Costs]![Overhead]*[BOM Build Item Table]![Qty]*[BOM]![Ext Qty]) AS Overhead, (0) AS [Rev Split]
FROM [BOM Build Item Table] INNER JOIN (BOM LEFT JOIN [Item Level Incremental Costs] ON BOM.[Cost Item] = [Item Level Incremental Costs].Item) ON [BOM Build Item Table].Item = BOM.Item;
SELECT [BOM Build Item Table].[Top Level Item], BOM.[Cost Item] AS Item, [BOM Build Item Table]![Qty]*[BOM]![Ext Qty] AS Qty, [BOM Build Item Table]![Level]+1 AS [Level], [BOM Build Item Table]![Sold Qty]*[BOM]![Sold Qty] AS [Sold Qty] INTO [BOM Build Item Table Temp]
FROM [BOM Build Item Table] INNER JOIN BOM ON [BOM Build Item Table].Item = BOM.Item;
SELECT [BOM Build Item Table Temp].[Top Level Item], [BOM Build Item Table Temp].Item, [BOM Build Item Table Temp].Qty, [BOM Build Item Table Temp].[Sold Qty], [BOM Build Item Table Temp].Level INTO [BOM Build Item Table]
FROM [BOM Build Item Table Temp];