473,692 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.SendObjec t - current record of form only.

1 New Member
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 12194
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Nita

Try sending a snapshot instead of a pdf using acFormatSNP

Mary
Aug 21 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
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

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

Similar topics

7
4621
by: Jay Bienvenu | last post by:
I am trying to execute a DoCmd.SendObject command to produce an email message from Access 2000. The command produces the email message, but the To:, CC: and BCC: fields are blank. The subject field and content come across fine. I can verify that the information isn't leaving Access. My client is experiencing the same problem. I tried it on two different computers; same problem.
4
9340
by: John | last post by:
Hi Is there a way to print/e-mail the current record as it appears on a form? Thanks Regards
1
9924
by: Alfred | last post by:
Hi I am using access 2002 1.0 I want to email a word or html file using the docmd.sendobject The document must be send as a attachment. 2.0 Second I would like to tell the Docmd.Sendobject to take the Info in a html or word document and to use it as the body of the email message. Is this possible. How can I do this. Thanks Alfred
2
5314
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another form that I want to show the record of the previous form I left. The problem is that the form does not show any other record but the current one from the previous form. I want it to open to that current record and it does however I can only view...
4
2195
by: Richard Cleaveland | last post by:
We have an Access 97 application which uses the DoCmd.SendObject method to send emails when a command button is activated. Our standard email client is Eudora. On all but one machine we have no trouble establishing Eudora as the default email client and having it work with Access. This other machine is a real problem and I'm soliciting suggestions. With the application open, and Internet explorer also open, if a "mailto" is selected...
8
12098
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
1
2222
by: bgreer5050 | last post by:
I am using Access 2000 and need a little help writing the code the proper way to do the following: I have a form with the following fields: "Requestor" and "RequestorEmailAddress" I have a subform with the following fields: "OpenPoNumber" I want to use the DoCmd.SendObject to send an email of the form to the
4
45969
by: magmike | last post by:
I've created a report for the purpose of printing a one page summary of a record. Of course, when I created the report, it gives me a page on every record. Can I create a button to open that report with just the results of that current record? And how do I modify the report to accept the buttons command? Thanks!
2
2148
easydoesit
by: easydoesit | last post by:
Hello all, I am looking for a way to be able to enter data into fields on a form, then be able to e-mail a report that shows only that record. This is what I have thus far: At the end of my Form, I have a Command Button. Right now the Command Button has an On Click... to basically E-mail a Report. Here is my Visual Basic code for it:
0
8547
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8970
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7639
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4564
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2984
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1962
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.