Hi, I'm in need of help with coding an SQL insert / update, either one needs to run depending if a product exists for an orderID.
I uploaded a video to youtube so you can see exactly what I'm trying to accomplish. It's best to watch the video before reading any further.
http://youtu.be/pXgyGJnHuOE
Here's the code I'm using for the 2 SQL inserts.
This is the insert for moving the bin inventory, it happens when the freezer is selected, I said in the video when I selected the unit however that's when it refreshes the inventory subform so the insert is actually visible. That doesn't change anything though and that's why I can change the unit as much as I want and it doesn't rerun the insert, the reason I put it on the freezer and disabled it after selecting one.
Code:
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunSQL "INSERT INTO Inventory (Product, OrderID) " & _
"SELECT ProductID, " & [Forms]![CreateOrders]![OrdersOrdersSubform]![OrderID] & " AS OrderID " & _
"FROM VendorInventoryLevel " & _
"WHERE (BarsLeft>0 Or BarsLeft<0) AND VendorID=" & [Forms]![CreateOrders]![VendorID] & ";"
DoCmd.SetWarnings True
And here's the code that runs when I click the "Give me inventory" button to move the van inventory.
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Inventory (Product, OrderID, BarsGiven) " & _
"SELECT ProductID, " & [Forms]![CreateOrders]![OrdersOrdersSubform]![OrderID] & " AS OrderID, " & "BarsLeft " & _
"FROM InventoryLevelVansSetForTransfer " & _
"WHERE (BarsLeft>0 Or BarsLeft<0) AND VendorID=" & [Forms]![CreateOrders]![CreateOrdersVansSetForTransfer]![VendorID] & ";"
DoCmd.SetWarnings True
Any ideas would be helpful.
Thanks