| |
|
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.
|
 |

01-14-04, 05:40
|
|
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], " _
|
|

01-14-04, 09:33
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 7
|
|
|
|

01-14-04, 09:42
|
|
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], " _
|
|

01-14-04, 09:51
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Preston, Lancashire, UK
Posts: 26
|
|
nope. that don't work....
|
|

01-14-04, 11:28
|
|
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"
|
|

01-14-04, 12:35
|
|
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
?
|
|

01-14-04, 13:22
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 7
|
|
last idea:
try only chr(10) or chr(13)
"text" & chr(10) & " newline text"
|
|

01-14-04, 14:29
|
|
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..
|
|

01-14-04, 15:44
|
|
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.
|
|

01-14-04, 17:06
|
|
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.
|
|

01-14-04, 21:14
|
|
Registered User
|
|
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
|
|
What Access are you using?
|
|

01-14-04, 22:16
|
|
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!
|
|

01-15-04, 03:16
|
|
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.
|
|

01-19-12, 17:18
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 3
|
|
|
best answer ever
Quote:
Originally Posted by aus
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|