Get a "newline" in a textbox, using a concatenation and controlsou

G

Guest

Hi,

I want to combine 2 memo inside a unique textbox and to display an empty
line between them. The textbox is part of a bound form and high enough to
display many lines. The form is based on a JOIN statement between tblAcademic
and tblClasses.

Here is the setting for the controlsource property in VBA:
txtReportTxt.ControlSource = "= IIF([tblClasses.ReportHd] Is Not Null AND
[tblAcademic.ReportHd] = Yes, [tblClasses.ReportHd] & Chr(13) & Chr(13),
"""") & [tblAcademic.ReportTxt]"

This code is run without errors. The IIF condition works fine. The problem
is that the Chr(13) has no effect in the textbox. Both memos are concatenated
one after the other as if the Chr function was not there. I have tried Chr(8)
and Chr(10) instead of Chr(13), but it does not change anything. The problem
also arises when I remove the IIF condition and write the concatenation
directly. When I try a random character using Chr, the character is well
placed as it should be, proving that Chr has a certain effect. I have also
tried String(2, 13), but the lack of effect is the same.

The only other possibility that I see is to add these backspaces at the end
of the first memo before saving it, but this would not be an elegant solution
as they should be constantly added and removed when the user edit the memo.

Any idea?
 
R

ruralguy via AccessMonster.com

Try adding a space to the sequence of vbCrLf

& " " & Chr(13) & Chr(10)
Hi,

I want to combine 2 memo inside a unique textbox and to display an empty
line between them. The textbox is part of a bound form and high enough to
display many lines. The form is based on a JOIN statement between tblAcademic
and tblClasses.

Here is the setting for the controlsource property in VBA:
txtReportTxt.ControlSource = "= IIF([tblClasses.ReportHd] Is Not Null AND
[tblAcademic.ReportHd] = Yes, [tblClasses.ReportHd] & Chr(13) & Chr(13),
"""") & [tblAcademic.ReportTxt]"

This code is run without errors. The IIF condition works fine. The problem
is that the Chr(13) has no effect in the textbox. Both memos are concatenated
one after the other as if the Chr function was not there. I have tried Chr(8)
and Chr(10) instead of Chr(13), but it does not change anything. The problem
also arises when I remove the IIF condition and write the concatenation
directly. When I try a random character using Chr, the character is well
placed as it should be, proving that Chr has a certain effect. I have also
tried String(2, 13), but the lack of effect is the same.

The only other possibility that I see is to add these backspaces at the end
of the first memo before saving it, but this would not be an elegant solution
as they should be constantly added and removed when the user edit the memo.

Any idea?
 
J

John Spencer

IF you want to put in a newline, you need to use Chr(13) & Chr(10) in that
order to get one new line.

I think you want the following.

txtReportTxt.ControlSource = "= IIF([tblClasses.ReportHd] Is Not Null AND
[tblAcademic.ReportHd] = Yes, [tblClasses.ReportHd] & Chr(13) & Chr(10) &
Chr(13) & Chr(10), """") & [tblAcademic.ReportTxt]"


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top