how to add a new line in a text field

  • Thread starter Thread starter witharebelyell
  • Start date Start date
W

witharebelyell

Hi

I have a text field - i want to put to new lines in the field - thru
code.

cr = Chr(13)
Forms!frm!comments = Forms!frm![comments] & cr & Me.Comment

The cr appears in the field as a a little square , how do i put a real
new line in there through code.

mike
 
Hi

I have a text field - i want to put to new lines in the field - thru
code.

cr = Chr(13)
Forms!frm!comments = Forms!frm![comments] & cr & Me.Comment

The cr appears in the field as a a little square , how do i put a real
new line in there through code.

mike

If you are doing this in VBA, then you can use the constants vbNewLine
or
vbCrLf:


Me!txtName="Hello" & vbCrLf & "World"


If you are doing this in the ControlSource of the text box, then you
need to
use Chr(13) and Chr(10) together:


="Hello" & Chr(13) & Chr(10) & "World"


If there is the possibility that some of the fields may be null, look
at using
the other concatenator, '+' in conjunction:


Me!txtName=Field1 & (vbCrLf+Field2) & (vbCrLf+Field3)


Jon
 
Hi

I have a text field - i want to put to new lines in the field - thru
code.

cr = Chr(13)
Forms!frm!comments = Forms!frm![comments] & cr & Me.Comment

The cr appears in the field as a a little square , how do i put a real
new line in there through code.

mike

In Access you MUST use chr(13) & chr(10) together (and in that order):

= Forms!frm![comments] & chr(13) & chr(10) & Me.Comment

In VBA you can use either chr(13) & chr(10) or vbNewLine or vbCrLf.

Forms!frm!comments = Forms!frm![comments] & vbNewLine & Me.Comment
 
Back
Top