[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2480
  • Last Modified:

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

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
Sivasan
Asked:
Sivasan
1 Solution
 
peter57rCommented:
Look at Sendoject in Help...example..


docmd.SendObject acSendQuery,"OrderviewQry",acformatxls,"xyz@abcd.com",,,"Subjectline"
0
 
SivasanAuthor Commented:
Thanks a million
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now