I have been trying to get this thing to work but without success My code is:
Code:
Private Sub Command35_Click()
Dim MYDATABASE1 As DAO.Database
Dim rsQryStockInhand As DAO.Recordset
Set MYDATABASE1 = CurrentDb()
Set rsQryStockInhand = MYDATABASE1.OpenRecordset("QryStockInhand", dbOpenDynaset)
rsQryStockInhand.MoveFirst
Do Until rsQryStockInhand.EOF
CurrentDb.Execute "UPDATE StockTakes SET Quantity = & rsQryStockInhand!StockInHand &, StockTakeDate = Date(); ", dbFailOnError
rsQryStockInhand.MoveNext
Loop
'clean up
rsQryStockInhand.Close
Set rsQryStockInhand = Nothing
Set MYDATABASE1 = Nothing
I am trying to take one record at a time from the table Stocktakes and update the value of the Quantity filed and StockTakeDate With the values from the query. The records on the table and the ones in the query should have the same order by ProductID. I could include a WHERE clause as you suggested before. I am just not sure if this procedure would do what I want to accomplish. The program keeps getting an error on the Currentdb.Execute UPDATE statement. The error says the following Run Time error 3075. Syntax error (missing operator) in query expression '& rsQryStockInhand!StockInHand &'. Do you know what this error means? Thank you for your help.