Solved

Access VBA - send query

Posted on 2011-03-16
4
339 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:murbro
  • 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:murbro
ID: 35149735
Thanks very much Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35150133
;-)
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

856 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