By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

Refer to Variable in Email Message

P: n/a
I have code behind the OnClick event of a command button. The code
creates an email message with a clickable hyperlink in the message
body. I want to reference one of the variables I declare (strYear) in
the body of the email as well. Here is the code - the variable I want
to reference is strYear:

Dim strYear As String
Dim strEmail As String
Dim strMailSubject As String
Dim strMsg As String

strYear = Me.YearTaken
strEmail = Me.txtEMail
strMailSubject = "Test"
strMsg = "I have completed a request for vacation and/or personal
holidays for strYear." & _
" Please click the hyperlink below to go to the database and
approve or reject my requested dates." & vbCrLf & vbCrLf & _
vbCrLf & "File://C:\Excel\Test.xls"

DoCmd.SendObject objecttype:=acSendNoObject, _
outputformat:=acFormatHTML, _
to:=strEmail, Subject:=strMailSubject, MessageText:=strMsg

I want the message in the email to say: "I have completed a
request...for 2003..." Can anyone offer a suggestion?

Thanks,
JD
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
JD,
cinch.... if strYear is *inside* quotes, it's treated as part of a
string, not a variable. So instead of this:
strMsg = "I have completed a request for vacation and/or personal
holidays for strYear."


You want this:

strMsg = "I have completed a request for vacation and/or personal
holidays for " & strYear & "."

(Note the strYear is *outside* the quotes.)

HTH,
Pieter
Nov 12 '05 #2

P: n/a
pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
JD,
cinch.... if strYear is *inside* quotes, it's treated as part of a
string, not a variable. So instead of this:
strMsg = "I have completed a request for vacation and/or personal
holidays for strYear."


You want this:

strMsg = "I have completed a request for vacation and/or personal
holidays for " & strYear & "."

(Note the strYear is *outside* the quotes.)

HTH,
Pieter


Thank you, Pieter.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.