Solved

Access VBA - send query

Posted on 2011-03-16
4
309 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
Comment Utility
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
Comment Utility
0
 

Author Closing Comment

by:murbro
Comment Utility
Thanks very much Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
;-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

771 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