Solved

MS Access - forcing a new line in a report text box using Expression Builder

Posted on 2009-05-14
12
2,084 Views
Last Modified: 2013-11-28
I am trying to force a new line in a text box in a report in MS Access.  For example, one of the things I am trying to do is build an address block.  I am a relative neophyte to Access, so I've been using the expression builder.  Things that I've tried so far:

=[Name] & vbcrlf & [Address] & vbcrlf & [Citystatezip]
- MS access adds brackets around the vbcrlf and it shows up as a query prompt when i run the report

=[Name] & "
" & [Address] & "
" & [Citystatezip]
- The carriage returns in the quotes are interpreted as an open square - all on one line.

Any other suggestions?  If this is only possible outside of expression builder, please make your explanation as simple as possible, since I am new!

THank you in advance!
0
Comment
Question by:TechRescue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +2
12 Comments
 
LVL 5

Expert Comment

by:DBDevl
ID: 24389639
Use 3 separate text boxes
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24390508
TechRescue,

I agree with DBDevl.
Why not just use 3 textboxes?
I mean, you have three separate fields anyway?

1. =[Name] & vbcrlf & [Address] & vbcrlf & [Citystatezip]
...This will only work in VBA code. (note the keword here is "VB"crlf)
;-)

If you want to use a the same characters in the textbox directly, use:
=[Name] & chr(13) & chr(10) & [Address] & chr(13) & chr(10) & [Citystatezip]

;-)

JeffCoachman
0
 

Author Comment

by:TechRescue
ID: 24390746
I wanted to use one textbox bc I cannot convince my boss that it is possible to have consistent line spacing.  She wants the report to look exactly like Word - no matter how I have formatted the spacing between the text boxes (even showing her with a ruler that they are the same) she will not believe me.  Was trying another way to convince her - running this report in Access would take seconds each time - doing it manually in Word takes hours......

That is my honest answer as to why I was starting this in the first place.....
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24390835
OK,

So did you try my suggestion of using the ASCI character codes insteado of vbcrlf?
0
 
LVL 3

Expert Comment

by:DK_User
ID: 24391926
I would agree about using 3 seperate textboxes, bc its the easiest and its the Access way. But having said that you could do it like this to please your boss.
Make a 'dummy' Label in the report, and name it 'AddressBlock'. You will probably have to write a little text in it at design time, or Access deletes it again.
Hide your 3 textboxes in the Report so that they dont show up.
In the Report's Load and Page Events you then put this code.
Try to avoid naming your Query field "Name" as it sometimes can confuse Access.
Thats why im naming it PersonName

Private Sub Report_Load()
Me.AddressBlock.Caption = Me.PersonName & vbCrLf & Me.Address & vbCrLf & Me.City
End Sub
 
Private Sub Report_Page()
Me.AddressBlock.Caption = Me.PersonName & vbCrLf & Me.Address & vbCrLf & Me.City
End Sub

Open in new window

0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 125 total points
ID: 24392175
TechRescue,

LOL!

Now with 3 experts suggesting using individual textboxes, I think it should be clear what the consensus is.
;-)
That coupled with the fact that it takes longer to do it "the bosses way"....
;-)

I never met a boss who would rather spend Hours rather than seconds
:-O

Jeff
0
 
LVL 2

Expert Comment

by:Joeyen5
ID: 24394812
Please try one of the following:

A) =[Name] & Chr(13) & Chr(10) & [Address] & Chr(13) & Chr(10) & [Citystatezip]

B) =[Name] & vbCrLf & [Address] & vbCrLf & [Citystatezip]


0
 

Author Comment

by:TechRescue
ID: 24396795
I think I managed to convince the boss to try it - you are all correct - seperate textboxes is by far the best (and how I originally set it up!)

Thank you
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24399130
Joeyen5,

That is what I suggested earlier. (Post 24390508)

The issue is that the asker wanted this in the textbox directly, so vbcrlf was not an option.

;-)

Jeff
0
 
LVL 2

Expert Comment

by:Joeyen5
ID: 24399348
Sorry about that boag2000, I didn't read your whole post.  I saw "3 text boxes" and kept going.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24399391
;-)
No sweat, I do it all the time too.
;-)

Enjoy your weekend.
;-)

Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24399432
TechRescue,

Thanks, but it would have been fairer to split the points evenly between the three posts that suggested the 3 texbox approach.

Or even more correctly, just give all the points to DBDevl, for being the "First" to post this suggestion.
;-)

Either way, I am OK with it.

Please click the "Request Attention" button in your original post to correct this.

;-)

Jeff
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question