473,395 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Send Object PDF to send current record only

Good Afternoon,

I have searched for a few days and found older fixes to this problem but nothing that is current to my version of Access (365) or current to the type of code that i am working with.

I have used this site for a few questions with this database, and have had amazing results. i am learning to find my own answers and figuring out how to do this while i have a smarter than me person guiding me through.

I am working with a single table and two form database.
the first form fills out a request and submits to request through clicking the save button.

the second form works the request and puts in their own information followed by sending a confirmation email to the original requester.

here is a copy of the Sendobject code that i have for my second form:

Option Compare Database
Option Explicit

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_save_Click()
  2.      Dim strName      As String
  3.      Dim dtDate       As Date
  4.      Dim strEmail     As String
  5.      Dim strMessage   As String
  6.      Dim strmsa       As String
  7.  
  8.      strName = Me.txt_prov_name
  9.      dtDate = Me.txt_completion_date
  10.      strEmail = Me.txt_prov_email
  11.      strmsa = Me.txt_who
  12.      strMessage = "Hello " & strName & "," & _
  13.          vbCrLf & "Your request has been completed.  Please review the changes made to your clinic and reply to this email if more changes are needed." & _
  14.          "There is no need to reply if the changes are correct." & "    " & "-" & strmsa
  15.  
  16.      Call DoCmd.SendObject(ObjectType:=acSendForm, _
  17.                            ObjectName:="Request - MSA", _
  18.                            OutputFormat:=acFormatPDF, _
  19.                            To:=strEmail, _
  20.                            Subject:="Clinic Change Request", _
  21.                            MessageText:=strMessage, _
  22.                            EditMessage:=True)
  23.  
  24. End Sub
  25.  
  26. Private Sub Form_Open(Cancel As Integer)
  27.  
  28.       Me.Filter = "[Work Completed By] is Null OR [Date Completed] is Null"
  29.       Me.FilterOn = True
  30.  
  31. End Sub
  32.  
  33. Private Sub Form_Timer()
  34.  
  35. MsgBox ("Refreshing Now, Press OK to continue")
  36.  
  37. End Sub
As you can see i have a few parts to this, the first part is that the form opens to only those requests that are not completed yet. Another part refreshes the query when i leave the form open to display a new request.

the largest part uses the record information to send an email with a snapshot of the completed form to the original requester's email in a PDF format.

this worked just fine, until i had two requests to complete.

both were filtered to view in the second form and when i hit save, the PDF displayed both of them in the email.

what i need is for the PDF to only send the single record that i am working on.

i found ACformatSNP instead of PDF, but that did not work at all and broke the form when i hit save......

I read that i need to create a report based on the specific record that i am working on and then set that as the send object.

I know next to nothing about Access, except what others on this forum have helped me learn.....so Green, New and multiple other things that i am, i need just a little bit more help on this before i go live.

Please do NOT do this for me, please help point me in the right direction, and guide my hands to type the correct line of code, so I can learn.

Right now I am understanding that I need to create a report that shows the current record and i need to export that to PDF......I don't even know the first thing about report.

Guiding Hands please teach me what i need to know.
Oct 3 '18 #1
4 2380
So after think about this for a while, i decided that i was going about this all wrong.

I decided to change the object that i was sending to just an email and import the data from the current record that i was viewing.

This is what i ended up changing the code to. I don't know if this even qualifies to leave this thread open or close and delete it, but this solution works great for me!!

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_save_Click()
  2.      Dim strName      As String
  3.      Dim dtDate       As Date
  4.      Dim strEmail     As String
  5.      Dim strMessage   As String
  6.      Dim strmsa       As String
  7.      Dim strclinic    As String
  8.      Dim strwhat      As String
  9.      Dim strcx        As String
  10.      Dim strcomments  As String
  11.      Dim strcompletion As String
  12.      Dim strdate      As String
  13.  
  14.  
  15.      strName = Me.txt_prov_name
  16.      dtDate = Me.txt_completion_date
  17.      strEmail = Me.txt_prov_email
  18.      strmsa = Me.txt_who
  19.      strclinic = Me.txt_clinic_name
  20.      strwhat = Me.txt_what
  21.      strcx = Me.txt__CX_MO_RE
  22.      strcomments = Me.txt_comments
  23.      strcompletion = Me.txt_completion_date
  24.      strdate = Me.txt_date
  25.      strMessage = "Hello " & strName & "," & _
  26.          vbCrLf & _
  27.          vbCrLf & "Your change request you made on " & strdate & " has been completed.  The details of the requested change are below." & _
  28.          vbCrLf & _
  29.          vbCrLf & _
  30.          vbCrLf & _
  31.          vbCrLf & _
  32.          vbCrLf & "The Clinic you requested to change was: " & strclinic & _
  33.          vbCrLf & _
  34.          vbCrLf & "This was a request to preform a " & strcx & " action" & _
  35.          vbCrLf & _
  36.          vbCrLf & "The requested change was made on: " & strcompletion & _
  37.          vbCrLf & _
  38.          vbCrLf & "The changes that were requested are: " & strwhat & _
  39.          vbCrLf & _
  40.          vbCrLf & "Adjusters Comments: " & strcomments & _
  41.          vbCrLf & _
  42.          vbCrLf & _
  43.          vbCrLf & _
  44.          vbCrLf & "Please review the changes made to your clinic and reply to this email if more changes are needed." & _
  45.          vbCrLf & _
  46.          vbCrLf & "There is no need to reply if the changes are correct." & _
  47.          vbCrLf & _
  48.          vbCrLf & "    " & "-" & strmsa
  49.  
  50.      Call DoCmd.SendObject(ObjectType:=acSendNoObject, _
  51.                            To:=strEmail, _
  52.                            Subject:="Clinic Change Request", _
  53.                            MessageText:=strMessage, _
  54.                            EditMessage:=True)
  55.  
  56. End Sub
  57.  
  58. Private Sub Form_AfterUpdate()
  59.  
  60. End Sub
  61.  
  62. Private Sub Form_Open(Cancel As Integer)
  63.  
  64.       Me.Filter = "[Work Completed By] is Null OR [Date Completed] is Null"
  65.       Me.FilterOn = True
  66.  
  67. End Sub
  68.  
  69. Private Sub Form_Timer()
  70.  
  71. MsgBox ("Refreshing Now, Press OK to continue")
  72.  
  73. End Sub
  74.  
Oct 3 '18 #2
zmbd
5,501 Expert Mod 4TB
DockBlack4444:
Your original post pop the older thread back into my message que... I've added an update there that may be of value to you
home > topics > microsoft access / vba > questions > send single record to email >Post#9
I've used the query as the object in the example; however, a report based on the query works just as well. As I noted in the update to the thread, I've been using this method for quite awhile now using acSendReport and acFromatPDF for the DoCmd.SendObject to send out reports to certain individuals.

Best of luck with your project
Oct 13 '18 #3
Looking for a small bit of guidance. everything is working just fine with the VBA codes that I learned. the only thing that I need help with is for the VBA code to close the form once the email finishes sending. any ideas?
Oct 31 '18 #4
twinnyfo
3,653 Expert Mod 2GB
Technically should be a new question, but such a simple one, I'll just throw it out here. Right after the e-mail sends, add this line:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close
Simple enough!

Hope this hepps!
Oct 31 '18 #5

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

Similar topics

1
by: Tim Graichen | last post by:
I currently populate a form based on a query. 1)How do I create a report that displays only the current record's fields and not all records in the table? Thanks Tim G
2
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...
2
by: OSMeier | last post by:
Hi Everyone, I am hoping you can help me. I am using MS Access 2000 for this. Here is the scenario: I have two tables: tblMain -------- ID (Primary Key)
0
by: user_5701 | last post by:
I have an Access 97 database front end (with some lookup tables there too) which also has a MS SQL Server 2000 back end, where all the rest of the larger tables are. I recently had some problems...
1
by: David | last post by:
Hi, I have a continuous form. For each record I have a field 'HeldDate' (Text Field from a table) Against each record I have a button which sets the visibility of this text box to 'True' and...
0
by: jennywhatley | last post by:
Hello I am using the following code to try to get a report to show a single record by clicking a command button in a sub form (perhaps it doesnt work because its a sub form not a form?) The...
0
by: Andy | last post by:
Hi ! I have a form that displays several records. The record contains a bound object frame. Onclick I execute some simple code to change teh object's appearance then I requery. The trouble...
2
by: Tim F | last post by:
Hello all, I would like to create a command button on a form that will allow the user to export the current record to .xls. The following exports the entire table. Is there a way to export the...
9
by: ChipStewart | last post by:
I'm trying to use a few posts from this forum, including use DoCmd.OutputTo to export a PDF of the current record on a report? to send a single record displayed in a form of my potential client data...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.