How would I go about deleting one field OrderPK after it is Updated to tblTempOrder?
How would I get Access to get the new OrderPK (AutoNumber) and enter the data into the sub table tblIndentOrderDetails
Code:
If blnBackOrder Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From tblTempOrder" 'Clear temp order table
DoCmd.RunSQL "Insert Into tblTempOrder Select * From tblIndentOrder Where OrderPK=" & [OrderPK] & "" 'Insert data to Temp table linking order number
DoCmd.RunSQL "Update tblTempOrder Set CustomerOrderNumber='" & strBackOrderNo & "', BOOrderFK='" & strBackOrderPK & "', Invoiced=False,InvoiceNo=Null,InvoiceDate=Null" 'change invoice info
DoCmd.RunSQL "Update tblTempOrder Set OrderPK=Null"
DoCmd.RunSQL "Insert Into tblIndentOrder Select * From tblTempOrder" 'Insert data from temp table to orders table
Me.Refresh 'refresh Orders table
.MoveFirst
How would I get Access to get the new OrderPK (AutoNumber) and enter the data into the sub table tblIndentOrderDetails
Code:
Do While Not .EOF
If Nz(!QtyShipped, 0) < !QtyOrdered Then
strSQL = "Insert Into tblIndentOrderDetail Values ('" & strBackOrderPK & "', '" & !PartNumberFK & "', " & !DiscountedPrice & ", QtyOrdered=" & (!QtyOrdered - Nz(!QtyShipped, 0)) & ", Null)"
DoCmd.RunSQL strSQL
End If
.MoveNext
Loop