3219 Invalid Operation - running an update query

S

Stapes

Hi
I have set up an update query with 4 parameters using CreateQueryDef:
"qryUpdSalesMandate".
When I try an run it using the following code: -

Dim db As Database, qd As QueryDef, rs As Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("qryUpdSalesMandate")
qd.Parameters("pCO").Value = Forms!FRM_Frontoffice4_T7_Selling!
T7_Contracting_Company
qd.Parameters("pSPOT").Value = mySpotMandate
qd.Parameters("pFWD").Value = myForwardMandate
qd.Parameters("pREMAIN").Value = myRemainingMandate
Set rs = qd.OpenRecordset

I get the error 3219 Invalid Operation.
I have tried running the query on its own and feeding it the same
parameters, and it worked.
Any ideas?

Stapes
 
D

Douglas J. Steele

Action queries (UPDATE, INSERT INTO, DELETE) don't generate recordsets, so
you can't use that approach.

Replace the

Set rs = qd.OpenRecordset

with

qd.Execute dbFailOnError
 

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