Adding a "Linefeed" in a Label/Text Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, from my VBA code I am creating a dynamic control Label and Text Box. I
need to force a "line feed" or "carriage return" in in the middle of the
text. I tried adding a Chr(10) and Chr(13) value to the string but this did
not work. For example,

Dim foo As String
foo = " some text "
foo = foo + Chr (13) ' ASCII Carriage Return Char
foo = foo + " some text"
Me.TextBox.TEXT = foo

This code does not work. Can someone provide a solution to this problem,

Thanks,
 
Eddie's Bakery and Cafe' said:
Hi, from my VBA code I am creating a dynamic control Label and Text Box.
I
need to force a "line feed" or "carriage return" in in the middle of the
text. I tried adding a Chr(10) and Chr(13) value to the string but this
did
not work. For example,

Dim foo As String
foo = " some text "
foo = foo + Chr (13) ' ASCII Carriage Return Char
foo = foo + " some text"
Me.TextBox.TEXT = foo

This code does not work. Can someone provide a solution to this problem,

Thanks,

Try this:

foo = foo & Chr (13) ' ASCII Carriage Return Char
 
Hi Jacco, I tried using the "&" but this did not work. Do you have another
suggestion?

Thanks for your help
 
Hi, from my VBA code I am creating a dynamic control Label and Text Box. I
need to force a "line feed" or "carriage return" in in the middle of the
text. I tried adding a Chr(10) and Chr(13) value to the string but this did
not work. For example,

Dim foo As String
foo = " some text "
foo = foo + Chr (13) ' ASCII Carriage Return Char
foo = foo + " some text"
Me.TextBox.TEXT = foo

This code does not work. Can someone provide a solution to this problem,

Thanks,

In Access you must use the chr(13) & chr(10) combination
IN THAT ORDER.

= "Line 1." & chr(13) & chr(10) & "Line 2."

In VBA you can also use vbCrLf or vbNewLine.

[SomeControl] = "Line 1." & vbCrLf & "Line 2."
 
Me.TextBox.TEXT = foo

You cannot access the Text property of a control (unless it has the focus).
Try

Me!textbox.Value = "foo" & vbCrLf & "foo again"


HTH


Tim F
 
Back
Top