Results 1 to 5 of 5

Export table data from access to excel with a command button

This is a discussion on Export table data from access to excel with a command button within the Microsoft Access forums, part of the Question Forums category; I've searched the net completely looking for a way to export my table data into a preexisting excel workbook without ...

  1. #1
    Board Regular
    Join Date
    Sep 2005
    Posts
    89

    Default Export table data from access to excel with a command button

    I've searched the net completely looking for a way to export my table data into a preexisting excel workbook without success. I would like to have a command button on a form that when clicked, will copy a table of data in to a "pre-named existing" workbook and a specific worksheet.

    Any help would be great, thanks.

  2. #2
    Board Regular
    Join Date
    May 2013
    Posts
    176

    Default Re: Export table data from access to excel with a command button


  3. #3
    Board Regular
    Join Date
    Sep 2005
    Posts
    89

    Default Re: Export table data from access to excel with a command button

    Quote Originally Posted by welshgasman View Post
    Thanks but not really. I am brand new at Access and don't know exactly where and how to insert the code into VBA. I have written many macros in excel but only a couple in Access. Also the code they are showing does not have an option to select a specific page to place the data. Currently I have a macro that will export the data into a blank workbook and name the sheet but I am wanting to have different buttons create different exports of data. Such as one tab would be for "completed" and another tab would be "not completed". I built the macro using the macro function in Access.

  4. #4
    Board Regular alansidman's Avatar
    Join Date
    Feb 2007
    Location
    Steamboat Springs
    Posts
    3,713

    Default Re: Export table data from access to excel with a command button

    In Welschgasman's link, this is the code you should be using as an example.

    Code:
    Public Sub xportQuery()
        DoCmd.TransferSpreadsheet TransferType:=acExport, SpreadsheetType:=acSpreadsheetTypeExcel9, TableName:="Query1", FileName:="C:\test\template.xlsx", Range:="exportRange"
    End Sub
    Alan Sidman
    Win 10--Office 2013

    Click below for a white paper on Data Base Design
    http://r937.com/relational.html



  5. #5
    Board Regular
    Join Date
    May 2013
    Posts
    176

    Default Re: Export table data from access to excel with a command button

    How you implement it is up to you.
    The most basic would be the Click event of a button as you mentioned.
    Change the names in the code to match.

    alansdman has pointed out what code on that page you need.
    If you read the page, it will explain the parameters as well.

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com