how to add a new line in a text field

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
 
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

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
 
F

fredg

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
 

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