MidnightRain
Programmer
I am trying to run an append query to update an item materials table with standard materials(which are saved in another standard materials table). When I enter a new order I want to run the query when I select an item. I have tested my append query and it does insert the material records, however, it does not append them to the correct order item number. The problem is that in my append query... I used "max function" in order to place the records in association with the last order item ID that was entered. This is close but what I need it to do is place the materials in association with the current order item ID (auto generated number) which is generated on my screen when I choose a new item however right now it only gets saved in the order item table when I close the screen so it is not the "max" record until it gets saved. My question I guess is...is there a way to run the query in my code but reference the current oitemID on my screen as opposed to the last saved? Maybe I need to put the select statement right in my code as opposed to calling the query do I? Here is the SQL of my query and the code I use to call it below... Any help would be appreciated I have been at this too long!!
Thanks
PARAMETERS lngItemID Long;
INSERT INTO tblOrderItemMaterials ( omItemMaterialsID, omItemID, omBomID, omQtyNeeded, omOitemID )
SELECT DISTINCT qryItemMaterialCreation.imID, qryItemMaterialCreation.imItemID, qryItemMaterialCreation.imBomID, qryItemMaterialCreation.imQtyNeeded, qryLastOrderItem.LastOrderItem 'comment - (This is the query looking up the maximum order item ID)
FROM qryLastOrderItem, tblItems INNER JOIN qryItemMaterialCreation ON tblItems.itemID = qryItemMaterialCreation.imItemID
WHERE (((qryItemMaterialCreation.imItemID)=[lngItemID]));
code.....
varItemID = Me.itemID.Value
Call RunQueryParameter_TSB("", qyItemMaterialCreationUpdate, cstrQueryParam_lngItemID, varItemID)
Me.lstMaterialsList.Requery
strOriginalSQL = Me.lstMaterialsList.RowSource
Thanks
PARAMETERS lngItemID Long;
INSERT INTO tblOrderItemMaterials ( omItemMaterialsID, omItemID, omBomID, omQtyNeeded, omOitemID )
SELECT DISTINCT qryItemMaterialCreation.imID, qryItemMaterialCreation.imItemID, qryItemMaterialCreation.imBomID, qryItemMaterialCreation.imQtyNeeded, qryLastOrderItem.LastOrderItem 'comment - (This is the query looking up the maximum order item ID)
FROM qryLastOrderItem, tblItems INNER JOIN qryItemMaterialCreation ON tblItems.itemID = qryItemMaterialCreation.imItemID
WHERE (((qryItemMaterialCreation.imItemID)=[lngItemID]));
code.....
varItemID = Me.itemID.Value
Call RunQueryParameter_TSB("", qyItemMaterialCreationUpdate, cstrQueryParam_lngItemID, varItemID)
Me.lstMaterialsList.Requery
strOriginalSQL = Me.lstMaterialsList.RowSource