Discussion Locked

Access 2002

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In Access 2002, how can I click on a command button and send an email containing an excel spreadsheet with the results of a query? The query should be ran at the same time. Can this be done?

Thanks

3 replies

by iht4

Try the following command

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

Examples as shown in help file: This code includes the Employees table in a mail message in Microsoft Excel format and specifies To, Cc, and Subject lines in the mail message. The mail message is sent immediately, without editing.

DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
"Nancy Davolio; Andrew Fuller", "Joan Weber", , _
"Current Spreadsheet of Employees", , False

Change the acsendtable to acsendquery should provide you with the result you are looking for.

Good luck

This discussion is closed to new replies.