Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

What I am doing wrong?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joao - 26 May 2008 16:40 GMT
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...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.