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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with SelStart when inserting character into text box by clicking a button

Status
Not open for further replies.

PeterMAS

Technical User
Apr 3, 2012
18
0
0
GT
I designed a keyboard on a sub form to insert letters with diacritics in a text box at the cursor. The following code works OK if I don't use my computer keyboard (that's a big if). At that point, it will only add text after the last character in the text box. Here is the code on a button to insert the character á. N.B. These aren't my object names, I changed them to make the code more readable.
SQL:
Private Sub cmdLcáInsert_Click()
Dim HoldValue As Integer
HoldValue = Forms!frmMain!fsbSub.Form!txtText.SelStart

Forms!frmMain!fsbSub.Form!txtText = _
Mid(Forms!frmMain!fsbSub.Form!txtText, 1, Forms!frmMain!fsbSub.Form!txtText.SelStart) & _
"á" & _
Mid(Forms!frmMain!fsbSub.Form!txtText, Forms!frmMain!fsbSub.Form!txtText.SelStart + 1)

Forms!frmMain!fsbSub.Form!txtText.SelStart = HoldValue + 1
Suggestions will be gratefully received. Thank you.
 
While I don't fully understand what you are trying to do. I did a quick test and anywhere I clicked in my textbox named text1 I could make the à appear with my code below.

<code>
Private Sub Text1_Click()
Dim newText As String
newText = Left(Text1, Text1.SelStart) & Chr(224)
newText = newText & Mid(Text1, Text1.SelStart + 1)
Text1 = newText
End Sub
</code>

Perhaps a better explaination of what you are attempting would bring more responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top