Solved

Creating a command to export records from a table to an Excel spreadsheet

Posted on 2013-01-17
4
280 Views
Last Modified: 2013-01-17
I would like to create a menu command that will export the records output from a query into an Excel spreadsheet. Currently this is accomplished by clicking on the "External Data" tab and selecting the "Excel" option (see attached). However, for the convenience of the user (who is not Access savvy),  I would like to create a command button in the menu that will accomplish the same thing. How would I do it?
0
Comment
Question by:geeta_m9
  • 2
  • 2
4 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 total points
ID: 38787864
use this code

docmd.transferspreadsheet acexport,10, "tablename","c:\folder\myexcel.xlsx", true
0
 

Author Comment

by:geeta_m9
ID: 38787882
What is the "10" parameter for?
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 38787894
you can also use

DoCmd.OutputTo acOutputTable, "tableName", acFormatXLSX, "c:\folder\Myexcel.xlsx", True


<What is the "10" parameter for? >
that is the excel format for A2007 and above

if you are using Excel2003, use

docmd.transferspreadsheet acexport,8, "tablename","c:\folder\myexcel.xls", true
0
 

Author Closing Comment

by:geeta_m9
ID: 38787952
I just tested it and it works great!

Thanks!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question about DB Schema 27 56
Cascading Combo boxes between 2 sub navigation forms 1 15
aggregate query? 20 50
sumifs excel 2013 3 15
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question