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

I don't remember carriage and return

P: n/a
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try:
MyString = string1 & Chr(13) & Chr(10) & string2

In VBA code, you can use the constant vbCrLf or vbNewLine:
MyString = string1 & vbCrLf & string2

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #2

P: n/a
Hi "JingleBEV",

In the Access2.0 days, it would have been "Chr$(10) & Chr$(13)" ... (well,
technically, it still works) but since Access97 "Chr$(10) & Chr$(13)" has
been replaced by "vbCrLf"

So to correct your string as posted...
string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & Chr$(10) & Chr$(13) & string2
Either way, here is an example of how I would have wrote this using a single
string variable for the message, along with another to represent the
carriage return:

***********************************
....
Dim Msg As String
Dim CR As String

CR = Chr$(10) & Chr$(13) ' Access 2.0
'CR = vbCrLf ' Access97

Msg = ""
'I am in the habit of ensuring that my string variables are empty before
proceeding

Msg = Msg & "this is the first string " & CR
Msg = Msg & "and this is the second string."

MsgBox(Msg)
....
***********************************
Don

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #3

P: n/a
Chr$(10) & Chr$(13) = LfCr

Chr$(13) & Chr$(10) = CrLf

Which can give different results

--
Terry Kreft
MVP Microsoft Access
"Don Leverton" <le****************@telusplanet.net> wrote in message
news:hj4Gc.59415$_5.28301@clgrps13...
Hi "JingleBEV",

In the Access2.0 days, it would have been "Chr$(10) & Chr$(13)" ... (well, technically, it still works) but since Access97 "Chr$(10) & Chr$(13)" has
been replaced by "vbCrLf"

So to correct your string as posted...
string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & Chr$(10) & Chr$(13) & string2
Either way, here is an example of how I would have wrote this using a single string variable for the message, along with another to represent the
carriage return:

***********************************
...
Dim Msg As String
Dim CR As String

CR = Chr$(10) & Chr$(13) ' Access 2.0
'CR = vbCrLf ' Access97

Msg = ""
'I am in the habit of ensuring that my string variables are empty before
proceeding

Msg = Msg & "this is the first string " & CR
Msg = Msg & "and this is the second string."

MsgBox(Msg)
...
***********************************
Don

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string into 2 or more lines. I did this long time ago, if I have the code like

this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2


Nov 13 '05 #4

P: n/a
Thanks to all your inputs
This is the one I was looking for
MyString = string1 & Chr(13) & Chr(10) & string2

and vbCrLf new to me. Thanks

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@per-qv1-newsreader-01.iinet.net.au...
Try:
MyString = string1 & Chr(13) & Chr(10) & string2

In VBA code, you can use the constant vbCrLf or vbNewLine:
MyString = string1 & vbCrLf & string2

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string into 2 or more lines. I did this long time ago, if I have the code like

this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.