Results 1 to 2 of 2
  1. #1
    system243trd is offline Novice
    Windows 2K Access 2003
    Join Date
    Nov 2011
    Posts
    27

    Export Query into Excel

    I am trying to create a button that exports data into a brand new Excel spreadsheet on my c:\ drive.



    Can anyone help?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Assume your query is called MonthlyActivity. Written for Access 2003 and Excel 2003. Try this:
    Code:
    Private Sub ExportQuery_Click()
    On Error GoTo Err_ExportQuery_Click
    Dim reportName As String
    Dim theFilePath As String
    
    
        reportName = "MonthlyActivity"
    
    
           
    theFilePath = "C:\Drive"
    theFilePath = theFilePath & reportName & "_" & Format(Date, "yyyy-mm-dd") & ".xls"
          
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, reportName, theFilePath, True
    
    
    MsgBox "Report has been run."
    
    
       
    
    
    Exit_ExportQuery_Click:
        Exit Sub
    
    
    Err_ExportQuery_Click:
        MsgBox Err.Description
        Resume Exit_ExportQuery_Click
        
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Export Query to Excel
    By Leon_SF in forum Import/Export Data
    Replies: 7
    Last Post: 03-21-2012, 09:07 PM
  2. Replies: 3
    Last Post: 10-07-2011, 07:49 AM
  3. Export a pass-through query to Excel
    By broon in forum Import/Export Data
    Replies: 0
    Last Post: 03-07-2011, 03:43 PM
  4. Export query to Excel
    By dev82 in forum Queries
    Replies: 15
    Last Post: 02-10-2011, 11:15 AM
  5. Export Query to Various Excel Files
    By dalet in forum Import/Export Data
    Replies: 7
    Last Post: 11-09-2009, 09:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums