Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to email the current record using SendObject

Status
Not open for further replies.

BFP

Technical User
May 18, 2000
52
US
I am trying to use a SendObject macro (assigned to a button on a form) to email the current record (and only the current record).&nbsp;&nbsp;Right now, all the records related to the form get emailed (with the &quot;Object Type&quot; set to form).&nbsp;&nbsp;It would appear that I need to change the object type (to Query perhaps).&nbsp;&nbsp;But if it needs to be a Query, how do I set up a query to display only the current record within the form?<br><br>Alternatively, if someone has a piece of VBA code that would do the job, I would appreciate that as well.<br><br>Thanks in advanced,<br><br>--Dan
 
VBA is your answer.<br>If you just want to send the characters like <br><br>Mary Smith<br>23232 54th street<br>Tampa, FL 3333<br>828-222-3333<br><br>Say &quot;Mary&quot; is in a text box on your form called FirstName<br>And &quot;Smith&quot; is in LastName<br>----------------------------------<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim wholename As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim Address As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim CityStZip As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim BodyText As String<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;wholename = Me![FirstName] & &quot; &quot; & Me![LastName]<br>&nbsp;&nbsp;&nbsp;&nbsp;Address = Me![Address]<br>&nbsp;&nbsp;&nbsp;&nbsp;CityStZip = Me![City] & &quot;, &quot; & Me![State] & &quot;&nbsp;&nbsp;&quot; & Me![zip]<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'Create message<br>&nbsp;&nbsp;&nbsp;&nbsp;BodyText = wholename & Chr$(10) & Chr$(13)<br>&nbsp;&nbsp;&nbsp;&nbsp;BodyText = BodyText & Address & Chr$(10) & Chr$(13)<br>&nbsp;&nbsp;&nbsp;&nbsp;BodyText = BodyText & CityStZip<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'E-mail above message<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.SendObject acSendNoObject, &quot;&quot;, acFormatTXT, &quot;To Email&quot;, , , &quot;Subject of Email&quot;, BodyText, False<br>----------------------------------<br><br>Now this code will get any textbox(es) on your form and add all of the text boxes together and then send that text to an e-mail automatically.<br>If you change the &quot;False&quot; at the end of the last line to &quot;True&quot; it will create an e-mail and then stop to let you add or make changes. Which you must then hit Send to make it go.<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Hi DougP!
I´m using this method to create an email to be sent. My problem is that I first created the procedure in access95. Now that I have upgraded to 2000 a strange thing happens. I set the edit parameter to true to be able to se the email. Now, everytime I close the email after reviewing it, access goes down because of some 'forbidden measure' (I don´t know the exact words in english since I´m using a swedish version). Have you ever encountered a problem like this, and in that case, do you know what I can do about it?
I´d really appreciate your help!
/Linus
 
Hello,

I copied the above formula. It worked only one time. I also added the command:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

one line below the DoCmd.SendObject ......

When I clicked the right arrow to add a new record and perform the same routine, the e-mail has never been generated. If I continue adding the records, no e-mail has ever generated at all.

I am looking for a solution with similar purpose. I would like to receive separate e-mail. I do not mind if it generates 10-20 e-mails because it is our purposes.

Do I need to use a DO...NEXT LOOP command? Please advise. Thanks.
 
According to Microsoft's Website, the latest securtiy service packs have put in safety guards in response to the rash of self-propagating worm viruses. There are some workarounds listed at Microsoft support (search for &quot;SendObject Method Fails Silently&quot;). I have not tried any of these yet, however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top