Adding a carriage return in a query

A

ANDY PHILLEY

I have a query that glues together several fields from a
table into a new field. I want to put a carriage return
in the mix. Is that possible?


Example:

Field 1 ANDY
Field 2 IS
Field 3 A BOY
Field 4 OF THE
FIELD 5 WORLD

Query: [FIELD1]&" "&[FIELD2] - CARRIAGE RETURN - [FIELD3]
&" "&[FIELD4]&[FIELD5]


OUTPUT in 1 cell

ANDY IS
A BOY OF THE WORLD
 
T

Ted Allen

Hi Andy,

I have always used Chr(13) & Chr(10) together. I believe
one is a line return and one is a line feed. I'm not
completely sure if both are necessary, one of those
things that I've always done without really thinking
closely about it (hopefully someone else will post if
there is an easier way. Using this, your formula would
become:

[FIELD1] & " " & [FIELD2] & chr(13) & chr(10) & [FIELD3]
& " " & [FIELD4] & " " & [FIELD5]

-Ted Allen
 
J

John Spencer (MVP)

Add a carriage return and linefeed characters - Chr(13) & Chr(10). Both are
required and in the stated order.

Field: Combined: Field1 & Field2 & Chr(13) & Chr(10) & Field3 & ...
 
F

fredg

Hi Andy,

I have always used Chr(13) & Chr(10) together. I believe
one is a line return and one is a line feed. I'm not
completely sure if both are necessary, one of those
things that I've always done without really thinking
closely about it (hopefully someone else will post if
there is an easier way. Using this, your formula would
become:

[FIELD1] & " " & [FIELD2] & chr(13) & chr(10) & [FIELD3]
& " " & [FIELD4] & " " & [FIELD5]

-Ted Allen

Ted,
You are correct. In a query (or in an Access Control source) you must
use both chr(13) & chr(10) in that order.

In a VBA code window, in addition to the above, you could also use
either vbNewLine or vbCrLf.
 
A

Andy

Rock ON!

That did it.

-----Original Message-----
Add a carriage return and linefeed characters - Chr(13) & Chr(10). Both are
required and in the stated order.

Field: Combined: Field1 & Field2 & Chr(13) & Chr(10) & Field3 & ...

ANDY said:
I have a query that glues together several fields from a
table into a new field. I want to put a carriage return
in the mix. Is that possible?

Example:

Field 1 ANDY
Field 2 IS
Field 3 A BOY
Field 4 OF THE
FIELD 5 WORLD

Query: [FIELD1]&" "&[FIELD2] - CARRIAGE RETURN - [FIELD3]
&" "&[FIELD4]&[FIELD5]

OUTPUT in 1 cell

ANDY IS
A BOY OF THE WORLD
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top