Solved

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

Posted on 2009-05-14
12
1,746 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
  • 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
 
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now