Full Version: Line Breaks within a text box on a report?
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
chuckie
I'm using access to print a letter to patrons. Not all of them have a company they are associated with so I have the following unbound text box which will print a company if there is one, but not leave a blank space if there is not:

=([First_Name]+" ") & ([Last_Name]+" ") & ([Company]+" ") & [Street] & [City] & ", " & [State] & " " & IIf(Len([zip])=5,Format([zip],"00000"),Format([zip],"00000-0000"))

My problem is that it prints everything out on one continuous line and I want to add in line breaks to split it up.

Can this be done? I've tried messing around with "vbcrlf" which I found searching on here, but I can't make it work.

I can resort to putting everything on its own line but then if there is no company for that person there will be a blank line between their name and address which would look stupid.

Any suggestions?
Gecko
Try:
=([First_Name]&" ")&([Last_Name]&" ")&IIf(IsNull([Company]),"",Chr(13)&Chr(10)&[Company])&Chr(13)&Chr(10)&[Street]&[City]&", "&[State]&" "&IIf(Len([zip])=5,Format([zip],"00000"),Format([zip],"00000-0000"))

vbCrLf is not recoqnized in SQL and therefore not in a control source either, it's purely for VBA.
so use Chr(13)&Chr(10) -- carriage return & line feed (or vice versa)

HTH,
Gecko
chuckie
Thank you Gecko, that conecept worked perfectly, and thanks for fixing up my code a bit too.

I appreciate it so much.

Thanks again!!!
Gecko
Glad to help.

Gecko
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.