Solved

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

Posted on 2013-01-17
4
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

688 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