Share via

Access Multi Line Text Box

Anonymous
2017-09-17T15:18:27+00:00

Hi.

I'm trying to programmatically add a New Line in a text box in my form in MS Access 2016.

I have set the Enter Key Behaviour of my TextBox to "New Line in Field".

My code is in the Form_Load sub and everything I try simply does not create a new line.

Sample of code I've tried (where TextBox is the name of my text box control):

Me.TextBox = "Line 1" & Chr(13) & Chr(10) & "Line 2"      '<<< Doesn't work...

Me.TextBox = "Line 1" & vbCrLf  & "Line 2"                       '<<< Doesn't work...

Me.TextBox = "Line 1" & vbNewLine & "Line 2"                 '<<< Doesn't work...

I've also tried updating the text property different ways, such as...

TextBox.SetFocus: TextBox.Text = "Line 1" & vbNewLine & "Line 2"                 '<<< Doesn't work...

TextBox.SetFocus: TextBox.Value = "Line 1" & vbNewLine & "Line 2"               '<<< Doesn't work...

Any help would be greatly appreciated!

Thanks,

chamchar

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-09-17T15:30:51+00:00

Alright, I found the solution.

The following worked.

Me.Controls("TextBox") = "Line 1" & vbCrLf & "Line 2"

Was this answer helpful?

5 people found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful