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!

DoCmd.SendObject question 1

Status
Not open for further replies.

cdgeer

IS-IT--Management
Apr 8, 2008
133
US
Could someone tell me if it is possible to populate the Subject line in an email with data from two different fields on a form?

Can't figure out the syntax to make this work.

Code:
Private Sub cmdEmailRecord_Click()

DoCmd.SendObject acSendQuery, Req_CurRec, acFormatXLS, , , , Me.Requirement_No & " " & Me.Requirement_Title, , False

End Sub
 
How about:

Code:
Private Sub cmdEmailRecord_Click()
Dim strMyField As String

strMyField = Me.Requirement_No & " " & Me.Requirement_Title
Debug.Print strMyField
DoCmd.SendObject acSendQuery, Req_CurRec, acFormatXLS, , , , strMyField, , False

End Sub

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks Andy,

You got me thinking in the right direction. This is ultimately what I got to work:

Code:
Private Sub cmdEmailRecord_Click()
DoCmd.Echo False

DoCmd.OpenQuery "EmailSubject", acNormal, acEdit

DoCmd.Close acQuery, "EmailSubject", acSaveNo

DoCmd.Echo True

stEmail = DLookup("[Expr1]", "EmailSubject")

DoCmd.SendObject acSendQuery, "Req_CurRec", acFormatXLS, , , , stEmail, , False

End Sub

The Expr1 represented a combination of two fields from the loaded form in which the Email cmdbutton resides.

"EmailSubject" query looked like this:
SELECT tblRequirements.Requirement_No, ("Requirement No:" & " " & [Requirement_No] & " " & "Requirement Title:" & " " & [Requirement_Title]) AS Expr1
FROM tblRequirements
WHERE (((tblRequirements.Requirement_No)=[Forms]![Requirements Management]![Requirement_No]));


Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top