K
Kirk P.
With considerable help from this DG, I've written this code that successfully
returns records from an Access db to Excel.
Sub Test()
Dim cn As ADODB.Connection
Dim rec As ADODB.Recordset
Dim nCol As Integer
Set cn = New Connection
Set rec = New Recordset
'Open the connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\oprdgv1\depart\Finance\" & _
"_Health Solutions Group\Customer\Customer.mdb" & ";"
'Open the recordset
rec.Open "SELECT * FROM tblTESTING" & ";", cn, adOpenForwardOnly,
adLockOptimistic
'Returns recordset to Excel, including the header record
For nCol = 1 To rec.Fields.Count
Sheets("Sheet1").Cells(1, nCol).Value = rec.Fields(nCol - 1).Name
Next nCol
Sheets("Sheet1").Cells(2, 1).CopyFromRecordset rec
Set rec = Nothing
Set cn = Nothing
End Sub
What I REALLY want to do now is use a "virtual recordset" as an argument in
another Excel function. Because the set of data I have exceeds Excels row
limitations, I have the data stored in Access, but need to use that data as
an argument in Excel's LINEST function. How would I proceed with this?
returns records from an Access db to Excel.
Sub Test()
Dim cn As ADODB.Connection
Dim rec As ADODB.Recordset
Dim nCol As Integer
Set cn = New Connection
Set rec = New Recordset
'Open the connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\oprdgv1\depart\Finance\" & _
"_Health Solutions Group\Customer\Customer.mdb" & ";"
'Open the recordset
rec.Open "SELECT * FROM tblTESTING" & ";", cn, adOpenForwardOnly,
adLockOptimistic
'Returns recordset to Excel, including the header record
For nCol = 1 To rec.Fields.Count
Sheets("Sheet1").Cells(1, nCol).Value = rec.Fields(nCol - 1).Name
Next nCol
Sheets("Sheet1").Cells(2, 1).CopyFromRecordset rec
Set rec = Nothing
Set cn = Nothing
End Sub
What I REALLY want to do now is use a "virtual recordset" as an argument in
another Excel function. Because the set of data I have exceeds Excels row
limitations, I have the data stored in Access, but need to use that data as
an argument in Excel's LINEST function. How would I proceed with this?