If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SQL - Force a new line

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-04, 05:40
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
SQL - Force a new line

I have the following code in a VB script within an Access form. I’m updating the contents of a memo field with a combination of data contained in two other fields. After the update I can separate the two pieces of data with a space, & ‘ ‘ &, but I don’t know the correct code to force a line between them. Please advise. Thanks.

strSQL = "UPDATE tblone, tbltwo SET tblone.MemoField = [tbltwo].[MemoField] & ' ' & [tbltwo].[Darren], " _
Reply With Quote
  #2 (permalink)  
Old 01-14-04, 09:33
zengelan zengelan is offline
Registered User
 
Join Date: Jan 2004
Posts: 7
windows uses a line feed and a carriage return for new lines.
so use \n \r in your string to define a new-line in windows. see
http://de2.php.net/manual/en/languag....syntax.double
Reply With Quote
  #3 (permalink)  
Old 01-14-04, 09:42
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
Like this?

strSQL = "UPDATE tblone, tbltwo SET tblone.MemoField = [tbltwo].[MemoField] & \n & [tbltwo].[Darren], " _
Reply With Quote
  #4 (permalink)  
Old 01-14-04, 09:51
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
nope. that don't work....
Reply With Quote
  #5 (permalink)  
Old 01-14-04, 11:28
zengelan zengelan is offline
Registered User
 
Join Date: Jan 2004
Posts: 7
sorry,
actually that was for php (here you have to use both : "\n \r")
but in vbscript and all vb apps these are the characters 10 und 13 in ascii
so it will be:

"my string in the first line" & chr(10) & chr(13) & "my string in the second line"
Reply With Quote
  #6 (permalink)  
Old 01-14-04, 12:35
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
The result in the updated field is:

Text1 • • Text2

but if i copy and paste this data from the Access table to a word doc it displays correctly:

Text1
Text2

?
Reply With Quote
  #7 (permalink)  
Old 01-14-04, 13:22
zengelan zengelan is offline
Registered User
 
Join Date: Jan 2004
Posts: 7
last idea:

try only chr(10) or chr(13)

"text" & chr(10) & " newline text"
Reply With Quote
  #8 (permalink)  
Old 01-14-04, 14:29
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
same result, the space displays as a small square. I’ve searched and it appears to be the way access handles ASCII code, I haven’t been able to find a solution yet, thanks for your help..
Reply With Quote
  #9 (permalink)  
Old 01-14-04, 15:44
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Access can't print a newline character in the table display. Try it with a form pulling data from the table. It will display.
Reply With Quote
  #10 (permalink)  
Old 01-14-04, 17:06
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
I gave that a whirl, the memofield in the form displayed the data the same, the two bits of data separated by two small squares.
Reply With Quote
  #11 (permalink)  
Old 01-14-04, 21:14
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
What Access are you using?
Reply With Quote
  #12 (permalink)  
Old 01-14-04, 22:16
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
I figured out your problem! Chr(10) is \n and Chr(13) is \r, so the order should be Chr(13) & Chr(10), not the other way around. Windows uses \r\n not \n\r!
Reply With Quote
  #13 (permalink)  
Old 01-15-04, 03:16
Darren_Taylor Darren_Taylor is offline
Registered User
 
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
doh and more doh! Thanks. I couldn’t see the woods for the trees. Cheers.
Reply With Quote
  #14 (permalink)  
Old 01-19-12, 17:18
blah deblah blah deblah is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
best answer ever

Quote:
Originally Posted by aus View Post
I figured out your problem! Chr(10) is \n and Chr(13) is \r, so the order should be Chr(13) & Chr(10), not the other way around. Windows uses \r\n not \n\r!
Has to be one of most helpful, concise responses I've read so far on all these boards. Helped me, too.

thx

~blah
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On