Solved

Subroutine to export query results and open Excel File

Posted on 2012-04-01
7
253 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 350 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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