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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending sub-form in email? 1

Status
Not open for further replies.

data1025

IS-IT--Management
Apr 14, 2004
29
US
I have a help ticket application, where I have the basic user info in a form, and then a sub-form with a date/time, last updated by, and a memo field with problem information. How can I email all the sub-form records that pertain to the ticket? I have the basic email working,
something like: message = "Help has been requested on: " & Subject & vbCrLf & "Date Entered: " & DateEntered & vbCrLf & Subject & vbCrLf & "Ticket #: " & TicketNumber & vbCrLf

Thanks,
Eric
 
I would create a Report with a subreport control that would display all of the records that you find on your subform. This report can include all the information on the main form as well. The command DoCmd.SendObject can be directed to send the email with all of the message info you want but with the report attached.

Syntax

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]

Post back if this is what you would like to do and I can help you with it.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Yes, I would like to proceed with this.

 
Okay, create a saved query with all the controls necessary for the report and use a criteria line that refers back to the record ID on the Main form.

Code:
Select A.* 
FROM [i]yourtablename[/i] as A 
WHERE A.[ID] = FORMS![[i]mainformname[/i]]![[i]ID_controlname[/i]];

Now use this query as the RecordSource for your report. The same records in the subform will be displayed. Use the DoCmd.SendObjects command to setup the email with the attached report.

Post back with any questions.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Bob,

I have followed your instructions and achieved the report, but I need some of the info from the main form included in the report. Since the report is based on the "history" subform, I only see fields from this table. How can I add another table to the same report?
 
Bob - I got it. Disregard last post.
 
Great. But, in answer just add the main form table to your query and link by the common field/s.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top