|
|
Title | Copy data from an Access database into an Excel spreadsheet using a SQL SELECT statement |
Keywords | ADO, Access, Excel, database |
Categories | Database, Office |
|
|
Execute a SELECT statement similar to this one:
SELECT * INTO [Excel 8.0;Database=C:\Test.xls].[Books] FROM Books
Thanks to Kent Finkle.
|
|
Private Sub cmdLoad_Click()
Dim cnSrc As New ADODB.Connection
Dim num_copied As Long
Screen.MousePointer = vbHourglass
DoEvents
cnSrc.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & txtAccessFile.Text & _
";"
cnSrc.Execute "SELECT * INTO [Excel 8.0;" & _
"Database=" & txtExcelFile.Text & "].[Books] FROM " & _
"Books", num_copied
cnSrc.Close
Screen.MousePointer = vbDefault
MsgBox "Copied " & num_copied & " records."
End Sub
|
|
|
|
|
|