3219 Invalid Operation - running an update query

  • Thread starter Thread starter Stapes
  • Start date Start date
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
 
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
 
Back
Top