|
-
Mar 31st, 2005, 07:00 AM
#1
Thread Starter
Junior Member
Run Query in Access from VBA
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.
-
Mar 31st, 2005, 07:14 AM
#2
Addicted Member
Re: Run Query in Access from VBA
if you fail to plan, you plan to fail
-
Mar 31st, 2005, 08:16 AM
#3
Thread Starter
Junior Member
Re: Run Query in Access from VBA
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
-
Mar 31st, 2005, 08:35 AM
#4
Re: Run Query in Access from VBA
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.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|