Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCopy data from an Access database into an Excel spreadsheet using a SQL SELECT statement
KeywordsADO, Access, Excel, database
CategoriesDatabase, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated