Question Entering a New Line into a text box

Clut

Registered User.
Local time
Today, 20:50
Joined
May 5, 2010
Messages
29
Hi,

I'm populating a text box via code, pulling various fields from a table and displaying them in a textbox.

example:
textbox:
field1:
this field contains some data

field2:
This field also contains some data

field3:
This field contains lots of data, and will easilly spread over 4 or 5 lines in the textbox.


I have set the enter key behaviour in the textbox to 'New Line' and when I write data into the text box, I have tried seperating the fields with vbcr, but this just gives me a little square box, and then the data carries on on the same line.

Can anyone help with getting line breaks into a textbox when populating the textbox via vba?
 
If you have set the keyboard behaviour to new line in field does it go to a new line when you press return? Does the layout of the textbox show more than one row of text?
 
Yes, if I go into the textbox manually I can press Enter to create a new line, and have multiple lines in the textbox.
 
Where are you experiencing the problem?
 
Isn't it just ctrl-enter for a new line? I'm not sure but I think the field has to be a memo.
 
try vbcrlf

carriage return on its own may not be sufficient.


but

textbox1 = textbox2 & vbcrlf & textbox3 & vbcrlf & "[no more data]"

should work without issues
 
I need to populate the textbox via code, writing the contents of multiple fields into the textbox, as follows:

me.myTextBox = rec("field1") & vbcr & vbcr & rec("field2") & vbcr & vbcr & rec("field3")
(code has been simplified for readability.. those are not my controls names or field names :) )

however this does not seperate the fields when they are witten into the textbox. Instead I get:

Data from field 1 □□ Data from field 2 □□Data from field 3
 
Oh, sorry I misread the post. Ignore me....
 
Thank you to both David, and Gemma-The-Husky... both your your solutions worked perfectly.

Thanks
 

Users who are viewing this thread

Back
Top Bottom