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...
John Spencer - 26 May 2008 17:25 GMT
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
'====================================================
> I have this code:
>
[quoted text clipped - 25 lines]
> Anyone????
> I think my DB isn't lockedwriting...
Chris O'C - 26 May 2008 17:31 GMT
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
>I have this code:
>
[quoted text clipped - 25 lines]
>Anyone????
>I think my DB isn't lockedwriting...
Joao - 27 May 2008 09:46 GMT
Thank you Chris... it worked! So simple... why we complicate??
> 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
[quoted text clipped - 36 lines]
> >Anyone????
> >I think my DB isn't lockedwriting...