Solved

Command button event to export access query to excel and attach to email

Posted on 2013-02-04
2
2,106 Views
Last Modified: 2013-02-04
Hi There,
I have form in access. I have a button on the form on click I export the result of a query in access to excel. I like to know if instead of saving it, if I can directly attach the excel as an attachment to a email to be send via outlook.
Code to export to excel

the on click event

Dim stDocName As String
Dim stLinkCriteria As String

'Export report to MS Excel
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "OrderviewQry", "C:\Temp\OrderReport.xls"
DoCmd.Beep

MsgBox "The Selected Orders will be exported to Excel and saved in"
------------------

thanks
S
0
Comment
Question by:Sivasan
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 38853236
Look at Sendoject in Help...example..


docmd.SendObject acSendQuery,"OrderviewQry",acformatxls,"xyz@abcd.com",,,"Subjectline"
0
 

Author Closing Comment

by:Sivasan
ID: 38853291
Thanks a million
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now