Hi June7, I think I got it.(see code below) I called a function (UpdateInStock) in my proceedure (Update_Inventory_Click) and passed it 2 arguments. Seems to work. Now I want to add a checkbox control to Orders and use it to limit the Update_Inventory_Click to a one time deal. Thank you for your help. If you'd like me to post the whole DB just let me know.
Code:
Private Sub Update_Inventory_Click()
Dim px As Integer
Dim p As Integer
Dim intI As Integer
Dim O_ID As Long
Dim strSQL As String 'SQL statement
O_ID = Me.Orders_ID
Dim dbsHT1 As Dao.Database
Dim rstUpDateInventory As Dao.Recordset
Dim rstParts_In_Stock As Dao.Recordset
Set dbsHT1 = CurrentDb
strSQL = "SELECT * FROM [Orders_Details Query] WHERE ( " & O_ID & " =[Orders_Details Query].Orders_ID );"
Set rstUpDateInventory = dbsHT1.OpenRecordset(strSQL, dbOpenDynaset)
'If the recordset is empty, exit.
If rstUpDateInventory.EOF Then Exit Sub
intI = 1
With rstUpDateInventory
Do Until .EOF
px = ![Qty_Ordered] * ![Part_Qty_Req]
p = ![Part_ID]
px = ![Parts_In_Stock] - px
UpdateInStock p, px 'Function call passing Part_ID and Adjusted Parts_In_Stock
.MoveNext
intI = intI + 1
Loop
End With
rstUpDateInventory.Close
dbsHT1.Close
Set rstUpDateInventory = Nothing
Set dbsHT1 = Nothing
End Sub
Public Function UpdateInStock(P_ID As Integer, P_Amt As Integer)
Dim ppx, pp As Integer
Dim dbsHT2 As Dao.Database
Dim rstParts_In_Stock As Dao.Recordset
ppx = P_Amt
pp = P_ID
Set dbsHT2 = CurrentDb
Set rstParts_In_Stock = dbsHT2.OpenRecordset("Parts", dbOpenTable)
With rstParts_In_Stock
.Index = "PrimaryKey"
.Seek "=", pp
.Edit
![Parts_In_Stock] = ppx
.Update
rstParts_In_Stock.Close
dbsHT2.Close
End With
Set rstParts_In_Stock = Nothing
Set dbsHT2 = Nothing
End Function