Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving cursor to a new line in a Memo Field

Status
Not open for further replies.

smsmail

Programmer
Aug 11, 2010
105
US
Hello,

I have tried vbnewline, Chr(13) & Chr(10), etc. in the On Enter, key press down Events to no avail.

What code is used to move the cursor to a
new line in a memo field.

Thanks in advance for your help.
 
Thanks for your help PWise.

I am doing something wrong. In the on enter event my code is:me.comments = me.comments & control+enter

Do I put control+enter on a property. If so, which property?

smsmail
 
how about
Private Sub Notes_Enter()
If Not IsNull(Me.Notes) Then
If Not Right(Me.Notes, 2) = vbCrLf Then
Me.Notes = Me.Notes & vbCrLf
Me.Notes.SelStart = Len(Me.Notes)
End If
End If
End Sub
 
Thanks MajP for your help....but that did not quite work ....again maybe I am doing something wrong.

It has to be a way to move to a new line in a memo field.

 
Private Sub Notes_Click()
DoEvents
Me.Notes.SelStart = Len(Me.Notes)
Me.Notes.SelLength = 0
End Sub

Private Sub Notes_Enter()
If Not IsNull(Me.Notes) Then
If Not Right(Me.Notes, 2) = vbCrLf Then
Me.Notes = Me.Notes & vbCrLf
End If
Me.Notes.SelStart = Len(Me.Notes)
Me.Notes.SelLength = 0
End If
End Sub
 
MajP...I found a what I was looking for.


On the "Other" tab of the property sheet, there is an option "Enter Key Behavior", there is an value option "New Line in Field"

It works!

Thanks so much for your help!
 
OK, We are talking apples and oranges.
The On Enter, is not the event when you hit the enter key. It is the event when you enter into a control from outside the control. My code automatically creates a new line and goes to the new line when you enter into the textbox. By either tabbing into it or clicking in it. The Enter Key Behavior is what happens when you select the enter key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top