Does anyone know if its possible to execute an Update query made in Access from VBA code. Im using ADODB.Recordset but I can only retrieve data from access select queries, I want to update the db from VBA using an update query in access.
Printable View
Does anyone know if its possible to execute an Update query made in Access from VBA code. Im using ADODB.Recordset but I can only retrieve data from access select queries, I want to update the db from VBA using an update query in access.
?VB Code:
ADODB.Execute
Im writing in Excel VBA, there is no ADODB.Execute command there.
My code is like this:
szConnect = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=H:\TIDREDOV.mdb;"
Set objCommand = New ADODB.Command
objCommand.ActiveConnection = szConnect
objCommand.CommandText = "UPDATE(...)SET....
objCommand.Execute RecordsAffected:=lRecordsAffected,
Options:=adCmdText Or adExecuteNoRecords
Which works fine, however I want to use a stored update query in Access instead of writing the query in the command text. I know how to retrieve data using a stored query(called Test), like this:
Set rsGetData = New ADODB.Recordset
rsGetData.Open "[Test]", szConnect, adOpenForwardOnly, adLockReadOnly, adCmdTable
I wonder if its possible to execute a stored update query and how u do that.
Best regards
Bjso
Uh I think you need to execute it (some what like you posted and was previously posted?)
Your object you declared is the ADODB ...
The Stored procedure, I haven't run before but should be the same as a query.
You may need to supply parameters though, in which case you'll need to read up on how to do this or see is szlamany can point you in the right direction.