Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I have the vba code below to run a sql query off an Access
database.... what I would like to do is change this code so that it can run off a table of data held in an excel file. Is this possible? Essentially, due to our fantastic network, I need to make one call to the database to get the full pipeline data and then run 4 SQL queries off the retrieved data. Each call to the data base takes about 5mins (due to network performance), so I was hoping to do one call and then manipulate in excel. Thanks Dim vConnection As New ADODB.Connection Dim rsPubs As ADODB.Recordset Dim db As String Set rsPubs = New ADODB.Recordset Set vConnection = New ADODB.Connection db = "data source=J:\Pipeline.mdb;" vConnection.ConnectionString = db & "Provider=Microsoft.Jet.OLEDB. 4.0;" vConnection.Open Sql1 = "SELECT x " Sql2 = "FROM y " Sql3 = "WHERE z; " Sql = Sql1 + Sql2 + Sql3 Debug.Print (Sql) ' vRecordSet.Open sql With rsPubs ' Assign the Connection object. .ActiveConnection = vConnection ' Extract the required records. .Open Sql Worksheets("All pipeline").Range("b7:iv65536").ClearContents Worksheets("All pipeline").Range("b7").CopyFromRecordset rsPubs .Close End With vConnection.Close Set rsPubs = Nothing Set vConnection = Nothing |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
QUERY EXCEL TABLE DATA | Excel Programming | |||
Running a SQL Update Query in Excel VBA | Excel Programming | |||
Running Data Table using an input that triggers DDE linked data | Excel Discussion (Misc queries) | |||
Web Query running in backg. -how to know when data retrieval compl | Excel Programming | |||
Excel 2000 Web query not returning all Table Data | Excel Programming |