469,138 Members | 1,383 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

Force Blank Line in Report Text Box

11
Access 2010
Windows

Hi....I have encountered a couple of questions that seem to have left me puzzled even though I was not expecting it to be difficult.

I am working on a report that will print a letter. I want my text box to be formatted like a paragraph. When setting up an email to send and going through code builder, I have previously used the chr(10) and chr(13) to do indents and carriage returns. I can not seem to get any of this to work inside the text box. This is what I currently have (although I have had this about 10 different ways trying to get it to work):

Expand|Select|Wrap|Line Numbers
  1. =IIf([Region]="EU",[txt_C_EU_MainLetter],[txt_C_nonEU_MainLetter]) & " We appreciate your support and wish you every success for " & [ctlNextYr] & "."
I want it to look like this when printed:
Text from [txt_C_EU_MainLetter] or [txt_C_nonEU_MainLetter]
<blank line>
We appreciate your support and wish you every success for xxxx.
Any suggestions? I would like to be able to do everything inside one text box.

Thanks so much.
Nov 29 '12 #1

✓ answered by ADezii

I assume that you are using this Expression in the Control Source of a Text Box. The Intrinsic Constant vbCrLf cannot be used, but you can Insert a Blank Line into the Expression as follows:
Expand|Select|Wrap|Line Numbers
  1. =IIf([Region]="EU",[txt_C_EU_MainLetter],[txt_C_nonEU_MainLetter]) & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) & " We appreciate your support and wish you every success for " & [ctlNextYr] & "."

7 3562
ADezii
8,800 Expert 8TB
I assume that you are using this Expression in the Control Source of a Text Box. The Intrinsic Constant vbCrLf cannot be used, but you can Insert a Blank Line into the Expression as follows:
Expand|Select|Wrap|Line Numbers
  1. =IIf([Region]="EU",[txt_C_EU_MainLetter],[txt_C_nonEU_MainLetter]) & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) & " We appreciate your support and wish you every success for " & [ctlNextYr] & "."
Nov 29 '12 #2
NeoPa
32,164 Expert Mod 16PB
A strange example to post of what you'd tried. As ADezii says, there's nothing in there that anyone would expect to produce a blank line. We're left guessing at what you tried and where. If you were using any VBA constants then you need to understand that these are not available to SQL, which is essentially what is dealing with the formula in your TextBox control.

If you struggle after ADezii's suggested code then come back to us. I know I've had new lines working happily in TextBoxes, so if you still have problems then it indicates something else we need to look at. Something about what you're doing which is unrelated to the currently posted details.
Nov 29 '12 #3
A12help
11
Thank you both. I was forgetting the "$", and only had chr(10), chr(13), etc. That solved my problem. Thanks again!
Dec 3 '12 #4
NeoPa
32,164 Expert Mod 16PB
The '$' on the end of these functions is not required. It is historical and not recommended use any more. If you had the same as this but without the '$'s then it should have worked exactly as this does. The actual difference between the two is that the dollar versions return an explicit string value whereas the versions without the '$' return a variant value of subtype string. There are extremely few scenarios where the difference would cause any issues.

Nevertheless, if your problem is solved then we needn't worry about that any more. Just so you understand the situation.
Dec 3 '12 #5
A12help
11
I continued researching this after posting my dilemma and came across an article indicating that this can sometime be an issue. I did not think the $ was required either however after reading the article, I tried it and it worked. Thank you for your feedback. Although I am not understanding why the $ would result in this working, nevertheless it did and that works for me.
Dec 4 '12 #6
zmbd
5,400 Expert Mod 4TB
Chr() uses and returns a variant, while Chr$() uses an
integer and returns a string.

Sometimes concatenation of a variant to a string will do weird stuff in that the parser will ignore some of "special" characters such as carrage return and line feed. However, when typecasting the returned value as a string, the parser read the results as just another charactor in the string and adds it without anticipating what the user wanted to output. Blame it on the programers trying to optimize performance.

Ran into this using the old teletype terminals. :)
Dec 4 '12 #7
NeoPa
32,164 Expert Mod 16PB
A12Help:
Although I am not understanding why the $ would result in this working, nevertheless it did and that works for me.
That's a fair comment. It's what you're after ultimately, after all.

I believe Z's post may well help to explain this, and I expect I could with hands-on of the db itself, but you have a solution, so I don't need to worry :-)
Dec 5 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by dan glenn | last post: by
3 posts views Thread by Miran Kopmajer | last post: by
6 posts views Thread by Timur Tabi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.