What I am doing wrong?

J

Joao

I have this code:

.....
Set BD = CurrentDb
.....

Public Function funcRunSQL(strCmdSQL As String)

Set rstSQL = BD.OpenRecordset( _
strCmdSQL, dbOpenDynaset)

rstSQL.Update

rstSQL.Close
BD.Close

End function


Calling the func:

SQLString = "UPDATE Processos SET Mes = 6, Ano = 1924 WHERE NrSubs = 87564;"

funcCorrerSQL SQLString

I get an error on the rstSQL SET:
"Error : 3219 Invalid Operation"

Anyone????
I think my DB isn't lockedwriting...
 
J

John Spencer

What are you trying to do? If you are trying to execute the query, you
might be able to use

CurrentDb().Execute strCmdSQL

That would be the entire procedure.

Public Function funcRunSQL(strCmdSQL As String)
CurrentDb().Execute strCmdSQL
End function



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
C

Chris O'C via AccessMonster.com

The sql statement must return a recordset. Therefore, you can't use an
action query. And funcCorrerSQL is probably a typo in your post which should
be funcRunSQL.

Use this to run your action query:

BD.Execute strCmdSQL, dbFailOnError

Chris
Microsoft MVP
 

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