Update Query Problem. Copy from one Table to Another

Stormrider83

Computer Science Student
Local time
Today, 21:03
Joined
Jul 16, 2008
Messages
26
Hi,

I simply want to copy the field Qty from Qry_Paint_Order_Parts to the field Qty in Tbl_Paint_Order_Parts where the records are joined by Part_No in both tables

I use the following code:

strSQL = ""
strSQL = strSQL & " UPDATE Tbl_Paint_Order_Parts "
strSQL = strSQL & " SET Qty = [Qry_Paint_Order_Parts].[Qty]"
CurrentDb.Execute strSQL

but get the error - too few parameters expected one.

Can anyone help? :confused:
 
strSQL = strSQL & " SET Qty = " & [Qry_Paint_Order_Parts].[Qty]


??
 
That was the alternate version of the third line in your code:

Code:
strSQL = ""
strSQL = strSQL & " UPDATE Tbl_Paint_Order_Parts "
strSQL = strSQL & " SET Qty = " & [Qry_Paint_Order_Parts].[Qty]
CurrentDb.Execute strSQL
 
Ah sorry Ken didnt notice you had changed it!

The new line of code gives me the error:

Run-time error '2465':

Microsoft Access can't find the field '|' reffered to in your expression.
 
This is my current code

strSQL = ""
strSQL = strSQL & " UPDATE Tbl_Paint_Order_Parts "
strSQL = strSQL & " SET Qty = " & [Qry_Paint_Order_Parts].[Qty]
CurrentDb.Execute strSQL
 
I have been advised to use the following code:

Code:
strSQL = ""
strSQL = strSQL & " UPDATE Tbl_Paint_Order_Parts "
strSQL = strSQL & " SET Qty = ( SELECT Qry_Sum_Paint_Order_Parts.Qty FROM Qry_Sum_Paint_Order_Parts WHERE Tbl_Paint_Order_Parts.Part = Qry_Sum_Paint_Order_Parts.Part_No )"
strSQL = strSQL & " WHERE EXISTS ( SELECT 1 FROM Qry_Paint_Order_Parts WHERE Tbl_Paint_Order_Parts.Part = Qry_Paint_Order_Parts.Part_No ) "
CurrentDb.Execute strSQL

But I still get the error too few parameters. Expected One
 

Users who are viewing this thread

Back
Top Bottom