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

Chr(13) not being accepted 2

Status
Not open for further replies.

borg2002

Programmer
Aug 7, 2002
84
US
Good afternoon,

I have written a program in vba that is being used to set and follow up the status of a product. The product is either activated or initiated for deletion. Either way, every time a change is recorded in the status, a notification mail is sent to one person. I use a form to display all the information about the product and another form to preview the mail message. Everything works fine, except... In the preview of the mail I merge the contents of three fields into the mailbody. I use Chr(13) to create a new linefeed but it never shows in preview although i the mail itself it is applied correct. I also tried Chr(10), but this didn't help either.

Is there anyone who can help me?
Code:

If StatusAct = True Then
subj = "Product " & Field1 & " - " & Field2 & " has been initiated for re-activation"
body = Field3 & Chr(13) & Field4 & Chr(13) & "Date : " & Now &Chr(13)
Else
subj = "Product " & field1 & " - " & Field2 & " has been initiated for deletion"
body = Field3 & Chr(13) & Field4 & Chr(13) & "Datum : " & txtCurDate & Chr(13)
End If

Thanks in advance
kind regards
Borg Exelmans
 
Hi,
Try using the constant vbCrLf instead of Chr(13).

Eg. "The line will break after " & vbCrLf & " the vbCrLf const" Hope it helps. Let me know what happens.
With regards,
PGK
 
Thanks very much PGK. It works!!! Any idea why Chr(13) fails?

Many thanks for your fast response...

kind regards
Borg
 
the reason pgk's solution will work is because vbCrLf is actually equivalent to Chr(13) & Chr(10)

If you replaced your Chr(13) with Chr(13) & Chr(10) that would work as well.


G LS
 
Thanks for the explanation. I'll never forget this one :-D

kind regards
Borg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top