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

Text box question

P: n/a
This seems like it should be easy, but I can't find the answer anywhere.
I need to combine text fields from several different records into one
text box for display purposes. Here's the code I'm using: (rstTable is
a recordset)

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13)
rstTable.MoveNext
Loop

The problem is the text box ignores the carriage returns. I get all the
text, but I need each record to be separated by at least one carriage
return, and right now the text runs together. I've tried using chr(10),
several constants (I don't remember exactly what they are, something
like abNewLine or abCrLf) but they are all ignored.

I can type in the texbox and enter carriage returns, but not when I'm
loading data from the database. I'm sure there's a simple answer, but I
can't find it! Thanks for the help.

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


P: n/a
ACCESS uses the combination of carriage return and line feed for a new line
(Chr(13) & Chr(10). This differs from some other MS Office software.

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13) & Chr(10)
rstTable.MoveNext
Loop
--

Ken Snell
<MS ACCESS MVP>

"Access User" <no************@somewhere.com> wrote in message
news:42***********************@visi.com...
This seems like it should be easy, but I can't find the answer anywhere. I
need to combine text fields from several different records into one text
box for display purposes. Here's the code I'm using: (rstTable is a
recordset)

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13)
rstTable.MoveNext
Loop

The problem is the text box ignores the carriage returns. I get all the
text, but I need each record to be separated by at least one carriage
return, and right now the text runs together. I've tried using chr(10),
several constants (I don't remember exactly what they are, something like
abNewLine or abCrLf) but they are all ignored.

I can type in the texbox and enter carriage returns, but not when I'm
loading data from the database. I'm sure there's a simple answer, but I
can't find it! Thanks for the help.

Paul

Nov 13 '05 #2

P: n/a
I thought I tried that, but I tried so many things I can't be sure.
I'll give it a try in the morning. Thanks.

Ken Snell wrote:
ACCESS uses the combination of carriage return and line feed for a new line
(Chr(13) & Chr(10). This differs from some other MS Office software.

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13) & Chr(10)
rstTable.MoveNext
Loop

Nov 13 '05 #3

P: n/a
You can also use vbNewLine..
txtBox.text = txtBox.text & rstTable!Description + vbNewLine
(I use the + rather than & so that if it is a null entry (no description) I
don't get two empty lines)

HTH

"Paul Pentz" <pp****@visi.com> wrote in message
news:42***********************@visi.com...
I thought I tried that, but I tried so many things I can't be sure. I'll
give it a try in the morning. Thanks.

Ken Snell wrote:
ACCESS uses the combination of carriage return and line feed for a new
line (Chr(13) & Chr(10). This differs from some other MS Office software.

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13) & Chr(10)
rstTable.MoveNext
Loop


Nov 13 '05 #4

P: n/a
I didn't try using +, but I know I tried vbNewLine, and it didn't work.
I ended up using a variable first, then copying the variable to the
text box. I'm new enough to Access that it doesn't make any sense to
me, but it worked. Here's what I did:

txtVariable = txtVariable & rstTable!Description & chr(13) & chr(10)

then when the loop finished...

txtBox.text = txtVariable

If someone can explain to me why that made a difference, I'd sure like
to know!

Paul
Mal Reeve wrote:
You can also use vbNewLine..
txtBox.text = txtBox.text & rstTable!Description + vbNewLine
(I use the + rather than & so that if it is a null entry (no description) I
don't get two empty lines)

HTH

"Paul Pentz" <pp****@visi.com> wrote in message
news:42***********************@visi.com...
I thought I tried that, but I tried so many things I can't be sure. I'll
give it a try in the morning. Thanks.

Ken Snell wrote:
ACCESS uses the combination of carriage return and line feed for a new
line (Chr(13) & Chr(10). This differs from some other MS Office software.

do until rstTable.EOF
txtBox.text = txtBox.text & rstTable!Description & chr(13) & Chr(10)
rstTable.MoveNext
Loop


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.