You don't do update queries with OpenRecordset. You can either execute a SQL UPDATE statement, or you can open a recordset with a SELECT query and loop through the records, updating one at a time.
Using a recordset to update:
Set rst = db.OpenRecordset("SELECT ..."
Do While Not rst.EOF
If IWantToUpdateThisRecord Then
rst.Edit
rst!Field1 = newValue
rst.Update
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Using an UPDATE query:
db.Execute "UPDATE Table1 SET Field1 = <newvalue> WHERE Field1 = <oldvalue>" Rick Sprague
Actually, I've never addressed the first question--good question!
Execute has a second argument that you can use to set locking and exclusive control options, similar to OpenRecordset. dbFailOnError and dbSeeChanges look like they would generate a run-time error you could trap so that you could try again after a moment. dbDenyWrite looks like it would give you exclusive control of the table.
You could also wrap the Execute call between BeginTrans and CommitTrans calls, if you want to have an all-or-nothing guarantee. Rick Sprague
Forgive me, I may be missing something obvious here, but why are you changing an existing quantity? It appears that you're basically trying to store a calculated result or a quantity that could be calculated. Correct me if I'm wrong.
Jerry,
It's an dynamic inventory amount which gets added to as product is produced and relieved when shipped out. Certainly open to other suggestions but I'm not sure how else I'd handle this. Seems crazy to relate the Produced & shipped tables considering that they'll just be getting larger & larger each day.
Gord,
Yes, it was a typo. One of these days I will get to the bottom of what makes these darn query's tick! ...... I hope anyways!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.