Running an update query

S

Stapes

Hi
I have set up my update query called "qryUpdSalesMandate"
I then refer to it in my code: -

Set qd = db.QueryDefs("qryUpdSalesMandate")

I set all my parameters: -

' this one is the record selector
qd.Parameters("pCO").Value =
Forms!FRM_Frontoffice4_T7_Selling!T7_Contracting_Company
' these are fields to be updated
qd.Parameters("pSPOT").Value = mySpotMandate
qd.Parameters("pFWD").Value = myForwardMandate
qd.Parameters("pREMAIN").Value = myRemainingMandate

But how do I run it? I tried this: -

Set rs = qd.OpenRecordset

but I get 3219: Invalid operation.

Ever get one of those days

Stapes
 
D

Douglas J. Steele

Action queries (UPDATE, INSERT INTO,. DELETE) don't actually create
recordsets.

All you need is:

qd.Execute

although I'd recommend

qd.Execute dbFailOnError

Using dbFailOnError as a parameter means you'll get a trappable error if
anything goes wrong with the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top