?
Solved

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

Posted on 2009-05-14
12
Medium Priority
?
2,253 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 375 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 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