Set rstSource = Nothing
Set conConnection = Nothing
If flgTrans Then conConnection.RollbackTrans: flgTrans = False
If Not rstSource Is Nothing Then
If rstSource.State = adStateOpen Then rstSource.Close
If Not conConnection Is Nothing Then
If conConnection.State = adStateOpen Then conConnection.Close
PopulateReceiverQueue1 = False
LogMsgError Err.Description, Err.Number, ModuleName$, "PopulateReceiverQueue1"
However I am trying to execute using command but so far without success
My new code goes like this
StrSQL = "INSERT INTO [Orders supplies] (OrderID, ProductID, SupplyToWarehouse) Values " & _
"(" & _
" SELECT OrderID AS OrderID, MaterialID AS ProductID, Warehouse AS SupplyToWarehouse" & _
" FROM [Materials] WHERE [Warehouse]='" & Me!CustomerID & "'" & _
" AND [UnitsInStock] >0" & _
If Not uRunSQL(StrSQL, "") Then GoTo WrapUp
The problem is in SQL string. Thanks in advance for any ideas.
That's invalid SQL; that needs to be the first field in the SELECT clause, to match up with the field in the INSERT INTO clause. It's sort of out in the middle of nowhere like that. Concatenate it in the same way you did the customer (without the single quotes if it's a numeric value).