Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running UPDATE and APPEND queries from Access in Excel

I use the code below to run an Access DB SELECT Query and place it in an
Excel Worksheet. Is it possible to adapt this code to run APPEND or UPDATE
queries using Excel's VBA Editor, and if so how do I go about the revisions?

Sub accessQuery(vSQL As String, strTab As String)
If conn Is Nothing Then Set conn = New ADODB.Connection
If conn.State = adStateClosed Then 'if not active
With conn
.Provider = "Microsoft.jet.oledb.4.0"
.Mode = adModeShareDenyWrite
.Open data1
End With
End If

Set rs = New ADODB.Recordset
rs.Open vSQL, conn, adOpenStatic, adLockReadOnly

Sheets(strTab).Activate
sglRows = 2
Cells(sglRows, 1).CopyFromRecordset rs
Range("A2").Select

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Running UPDATE and APPEND queries from Access in Excel

http://erlandsendata.no/english/inde...badacexportado

This shows how to append data to an Access Table from Excel using VBA.
Re an update query, you can probably figure out how to loop through
the recordset and update the fields you want from Excel data.

Hth,
Merjet


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste Append from Excel to Access ibeetb Excel Programming 1 February 27th 06 04:29 PM
Running SQL queries for Access using Excel VBA ibeetb Excel Programming 2 August 31st 05 07:56 AM
Running Queries to Oracle from Excel 2000 Kevin Excel Programming 3 February 25th 05 08:57 PM
Running Access queries from Excel smartchick Excel Programming 4 January 3rd 05 11:23 AM
use vba in excel to append data in access sakijung[_2_] Excel Programming 0 April 7th 04 07:16 AM


All times are GMT +1. The time now is 08:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"