Solved

Access VBA - send query

Posted on 2011-03-16
4
354 Views
Last Modified: 2012-08-14
Hi

How do I update the following code so that the query gets sent in the body of the email.
Also it doesn't get sent automatically. I have to  press the send button. I don't want to have to.
Sub SendDatesEntered(ByVal sEmail As String)
On Error GoTo EH
    
    DoCmd.SendObject acSendQuery, "Dates Entered in Performance", acFormatPDF, sEmail, "graham@ses-sa.co.za", "admin@macros-vba.com", "Lesedi Performance dates entered", "These are the dates entered into the Performance database", , True
Exit Sub
EH:
   'MsgBox "There was an error sending a report " & Err.Description


End Sub

Open in new window

0
Comment
Question by:Murray Brown
[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
  • 3
4 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35149560
To send the email automatically:

DoCmd.SendObject acSendQuery, "Dates Entered in Performance", acFormatPDF, sEmail, "graham@ses-sa.co.za", "admin@macros-vba.com", "Lesedi Performance dates entered", "These are the dates entered into the Performance database", , False

...But the help files on the SendObject Method explains all of these options...


Embedding the query IN the body of the email takes a bit more work.
I'm at the office now, I am sure another Expert can help with that portion of your Q

;-)

JeffCoachman
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 35149631
0
 

Author Closing Comment

by:Murray Brown
ID: 35149735
Thanks very much Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35150133
;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

617 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