hurtsmyhead
Technical User
- Jun 3, 2010
- 8
Wazzup everybody,
I got the code below from another thread--it's from MajP and it works great, with one little issue...
I'm using it on double click to add a small bit of text to a Memo field on my form, right at the cursor position where I'm double clicking. Sometimes the total amount of text in the memo field is larger than the physical size I've allotted for it on my form, so it scrolls. In this situation, when I'm scrolled down to one of the lines at or near the bottom and double click to add the text, the text adds just fine but the cursor shoots back to or near the top of the field and and the field has scrolled back all the way (I can see the first line of text again).
This behavior does not occur if I'm using it on a line that's above the point where I have to scroll--the cursor stays right where I just double clicked. Hope that makes sense. Is there any way to stop this scrolling up behavior and keep the cursor where it was?
Private Sub Details_DblClick(Cancel As Integer)
Dim strTextbegin As String
Dim strTextEnd As String
Dim strTextInsert As String
Dim pos As Integer
strTextInsert = "<br />"
Dim ctl As Access.TextBox
Set ctl = Details
ctl.SetFocus
pos = ctl.SelStart
strTextbegin = Left(ctl.Text, pos)
strTextEnd = Mid(ctl.Text, pos + 1)
ctl.Text = strTextbegin & strTextInsert & strTextEnd
End Sub
I got the code below from another thread--it's from MajP and it works great, with one little issue...
I'm using it on double click to add a small bit of text to a Memo field on my form, right at the cursor position where I'm double clicking. Sometimes the total amount of text in the memo field is larger than the physical size I've allotted for it on my form, so it scrolls. In this situation, when I'm scrolled down to one of the lines at or near the bottom and double click to add the text, the text adds just fine but the cursor shoots back to or near the top of the field and and the field has scrolled back all the way (I can see the first line of text again).
This behavior does not occur if I'm using it on a line that's above the point where I have to scroll--the cursor stays right where I just double clicked. Hope that makes sense. Is there any way to stop this scrolling up behavior and keep the cursor where it was?
Private Sub Details_DblClick(Cancel As Integer)
Dim strTextbegin As String
Dim strTextEnd As String
Dim strTextInsert As String
Dim pos As Integer
strTextInsert = "<br />"
Dim ctl As Access.TextBox
Set ctl = Details
ctl.SetFocus
pos = ctl.SelStart
strTextbegin = Left(ctl.Text, pos)
strTextEnd = Mid(ctl.Text, pos + 1)
ctl.Text = strTextbegin & strTextInsert & strTextEnd
End Sub