Results 1 to 3 of 3
  1. #1
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19

    Export Query Data to Excel

    Can you please give me step by step instructions on how to export the result of my query from ACCESS database to EXCEL on a BUTTON CLICK.



    My butoon name is BUTTON1
    Query name is QUERY1
    Location of file is \\example.com\doc\EV-GRP\Ventures\Projects\ProjectExecution\MOC_Stuf
    File name is EXCEL1

    The filename has to be new every time so that previous record are not lost.

    Please advice.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Select the button , look at the properties
    In the EVENT tab of the button property, click on the ONCLICK event box, click the elipsis button right of that box,
    you will now be in code environment
    paste this code

    Code:
    Public Sub BUTTON1_ONCLICK()
    Dim vFile, vQry, vSheet
    
    
    vQry = "QUERY1"
    vFile = " \\example.com\doc\EV-GRP\Ventures\Projects\ProjectExecution\MOC_Stuf.xls"
    vSheet = "Data"
    
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, vQry, vFile, True, vSheet
    
    End Sub

  3. #3
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19
    Thanks....

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

Similar Threads

  1. Export data to excel
    By joanas in forum Access
    Replies: 4
    Last Post: 03-02-2015, 10:44 AM
  2. Replies: 5
    Last Post: 02-03-2014, 03:06 AM
  3. How to export all data to excel?
    By s128 in forum Import/Export Data
    Replies: 5
    Last Post: 06-17-2013, 01:22 PM
  4. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  5. Replies: 3
    Last Post: 10-07-2011, 07:49 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