Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Subroutine to export query results and open Excel File

Posted on 2012-04-01
7
Medium Priority
?
255 Views
Last Modified: 2012-04-01
I have gotten a lot of help on EE with creating a form that will allow the user to automatically import a spreadsheet into a table.  

Now, I'd like to create a subroutine that I can call from a button that will export a query (based on this imported table) into Excel, then open the Excel document.

Can someone help with this?
0
Comment
Question by:BBlu
[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
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
suvmitra earned 1400 total points
ID: 37794585
Use the default Macro available in MS Access for exporting a query to excel sheet. or use the code.

Dim Output_Path_And_File As String
Output_Path_And_File = "C:\ThePath\TheFile.xlsm"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "QueryName", Output_Path_And_File, True,""
0
 

Author Comment

by:BBlu
ID: 37794589
I think I'll use your method, but could you tell me where to find the default macro.
0
 
LVL 9

Expert Comment

by:suvmitra
ID: 37794598
You go to Macro -- in MS Access -- Create New Macro -- there you will find options like transfer spreadsheets or output to ..etc
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:BBlu
ID: 37794618
I don't see that option on the Ribbon
Access-Ribbon.jpg
0
 
LVL 9

Expert Comment

by:suvmitra
ID: 37794626
Can you show me what are there in the Create Tab?

Macro
0
 

Author Comment

by:BBlu
ID: 37794652
Oh, I see that. Sorry.  I saw it and selected the "ExportWithFormatting" option.  After playing with it for a while, I got it to work.  Thanks.
0
 

Author Closing Comment

by:BBlu
ID: 37794654
Tanks, suvmitra!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

721 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