469,898 Members | 2,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

DoCmd.SendObject - current record of form only.

1
Hi,

I have no background in scripting (barr HTML) and need some help with hashing out a VB script for a database I'm working on.

What my goal is, is to have a single record of a form which is the current focus emailed as PDF to a recipient. I am using Access 2007 and have the export to PDF plugin.

The code I have currently got (see below) is successfully emailing a PDF to the recipient, however it is exporting all the records in the table to PDF in the form layout.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command48_Click()
  2. On Error GoTo Err_Command48_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stEmail As String
  6.     Dim stSubject As String
  7.  
  8.     stDocName = "Flight Catering"
  9.     stEmail = "my@email.com.au"
  10.     stSubject = "XR Catering"
  11.  
  12.     DoCmd.SendObject acSendForm, stDocName, acFormatPDF, stEmail, , , stSubject, , , False
  13.  
  14. Exit_Command48_Click:
  15.     Exit Sub
  16.  
  17. Err_Command48_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_Command48_Click
  20.  
  21. End Sub
  22.  
What I need it to do is email only the currently focussed record in the form. A couple of other things I would like to do is have the email subject show the date and flight fields of the form for the record that is in focus ie "XR Catering for Flight (FLIGHT), (DATE)."

If anyone could please help with fine tuning this, it would be greatly appreciated.

Regards

Nita
Aug 21 '07 #1
2 11858
MMcCarthy
14,534 Expert Mod 8TB
Hi Nita

Try sending a snapshot instead of a pdf using acFormatSNP

Mary
Aug 21 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
The following code should do what you need...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command48_Click()
  2. On Error GoTo Err_Command48_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stEmail As String
  6.     Dim stSubject As String
  7.  
  8.     stDocName = "Flight Catering"
  9.     stEmail = "my@email.com.au"
  10.     stSubject = "XR Catering for Flight " & Me!Flight & ", " & Me![Date]
  11.  
  12.     DoCmd.SendObject acSendForm, stDocName, acFormatSNP, stEmail, , , stSubject, , , False
  13.  
  14. Exit_Command48_Click:
  15.     Exit Sub
  16.  
  17. Err_Command48_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_Command48_Click
  20.  
  21. End Sub
  22.  
Aug 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by John | last post: by
2 posts views Thread by Tony | last post: by
4 posts views Thread by Richard Cleaveland | last post: by
1 post views Thread by bgreer5050 | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.