Combine / Concatenate text and include a carraige return

  • Thread starter Thread starter ruperthouse
  • Start date Start date
R

ruperthouse

In my Access report I would like the fields: address, town, county, postcode
to be combined but put on separate lines. I don't want to use separate
unbound boxes for them as sometimes address is a different number of lines or
town or county is blank and I don't want blank lines.

Is there a syntax for carriage return so I can use something like

[address] & CR & [town] & CR & [county] & " " & [postcoe] where CR is the
carriage return symbol.

I've trawled help but can't find it.
 
In my Access report I would like the fields: address, town, county, postcode
to be combined but put on separate lines. I don't want to use separate
unbound boxes for them as sometimes address is a different number of lines or
town or county is blank and I don't want blank lines.

Is there a syntax for carriage return so I can use something like

[address] & CR & [town] & CR & [county] & " " & [postcoe] where CR is the
carriage return symbol.

I've trawled help but can't find it.

In Access the chr(13) & chr(10) combination (in that order) will give
you a carriage return and line space.
In the control source of an unbound control, write:
= [address] & chr(13) & chr(10) & [town] & chr(13) & chr(10) &
[county] & " " & [postcoe]

In VBA you can use the above chr(13) & chr(10) combination or the VBA
contstants:
vbCrLf
or
vbNewLine

=[address] & vbNewLine & [town] etc....
 
You can't use vb constants in a control source or query expression. You can use
=[Field A] & chr(13) & chr(10) & [Field B] & Chr(13) & Chr(10) & [Field C]

--
Duane Hookom
Microsoft Access MVP


PieterLinden via AccessMonster.com said:
ruperthouse said:
In my Access report I would like the fields: address, town, county, postcode
to be combined but put on separate lines. I don't want to use separate
unbound boxes for them as sometimes address is a different number of lines or
town or county is blank and I don't want blank lines.

Is there a syntax for carriage return so I can use something like

[address] & CR & [town] & CR & [county] & " " & [postcoe] where CR is the
carriage return symbol.

I've trawled help but can't find it.

instead of CR use vbCrLf. So your unbound textbox's control source would be
[address] & vbCrLf & [town] & ", " & vbCrLf & [county] & " " & [postcode]
 
Back
Top