How to insert a New Line into a text field?

  • Thread starter Thread starter Ryan Langton
  • Start date Start date
R

Ryan Langton

How do I insert a new line into an nvarchar field?

If I'm using Access, I can set the Enter key behavior for a text field to go
to a new line. When I look at the table data, it appears as new lines. If
I'm not using an Access form however to input the data (I want my VB code to
insert a new line and some text to the field), how do I do that?

Thanks,
Ryan
 
Me.MyControl = "This is the first line." & vbCrLf & "This is the second
line."
 
Sorry I wasn't clear. This would work if I have a control for said field on
the form. I do not have a control (for this particular field) on the form.
When the user performs a certain action, I want to insert (directly into an
nvarchar field in my SQL database) a newline followed by text. So for
example I would think I could do this with an UPDATE statement... 'UPDATE
table SET fieldA = fieldA + \n + "my added text"'... or something like that?

Thanks,
Ryan
 
Try SET fieldA = fieldA + Char(13) + Char(10) + "my added text"'

(Char(13) is Carriage Return, Char(10) is Line Feed)
 
Back
Top