[AccessD] Simulate tab in a plain text textbox

Ryan W wrwehler at gmail.com
Mon Apr 3 12:27:45 CDT 2023


Does anyone have some slick code to simulate pressing tab in a plain text
textbox?

this is what I've got now:

Option Compare Database
Option Explicit
Private lPos As Long
Private lTabCnt As Long

Private Sub Narrative_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode <> vbKeyTab Then
        lPos = Me!Narrative.SelStart
        lTabCnt = 0
    End If
    If KeyCode = vbKeyTab Then
        Dim leftTxt As String, rightTxt As String, tabPOS As Long
        KeyCode = 0
        lTabCnt = lTabCnt + 1
        tabPOS = lPos + (lTabCnt * 4)
        leftTxt = left(Me!Narrative, lPos)
        rightTxt = Mid(Me!Narrative, lPos + 1)
        Me!Narrative = leftTxt & Space(4) & rightTxt
        Me!Narrative.SelStart = tabPOS
    End If
End Sub

Private Sub Narrative_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    lPos = Me!Narrative.SelStart
End Sub


It seems to work for most scenarios, but it flashes as if I'm highlighting
the text when I press tab.  Application.Echo and SetPainting have no effect.


More information about the AccessD mailing list