P
Pete Provencher
I have an unbound text box (CurrentAbstractor) that when it is populated
with a single character I want it to tab to the next field (SearchTMS). I
have the following settings:
CurrentAbstractor
AutoTab = Yes
Tab Stop = Yes
Tab Index = 0
SearchTMS
AutoTab = No
Tab Stop = Yes
Tab Index = 1
To set the length of CurrentAbstractor I use the following
Private Sub CurrentAbstractor_KeyPress(KeyAscii As Integer)
Call LimitKeyPress(Me.CurrentAbstractor, 1, KeyAscii)
End Sub
_________________________________________________
Private Sub CurrentAbstractor_Change()
Call LimitChange(Me.CurrentAbstractor, 1)
End Sub
_________________________________________________
Sub LimitKeyPress(ctl As Control, iMaxLen As Integer, KeyAscii As Integer)
On Error GoTo Err_LimitKeyPress
' Purpose: Limit the text in an unbound text box/combo.
' Usage: In the control's KeyPress event procedure:
' Call LimitKeyPress(Me.MyTextBox, 12, KeyAscii)
' Note: Requires LimitChange() in control's Change event also.
If Len(ctl.Text) - ctl.SelLength >= iMaxLen Then
If KeyAscii <> vbKeyBack Then
KeyAscii = 0
Beep
End If
End If
Exit_LimitKeyPress:
Exit Sub
Err_LimitKeyPress:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_LimitKeyPress
End Sub
____________________________________________________
Sub LimitChange(ctl As Control, iMaxLen As Integer)
On Error GoTo Err_LimitChange
' Purpose: Limit the text in an unbound text box/combo.
' Usage: In the control's Change event procedure:
' Call LimitChange(Me.MyTextBox, 12)
' Note: Requires LimitKeyPress() in control's KeyPress event also.
If Len(ctl.Text) > iMaxLen Then
MsgBox "Truncated to " & iMaxLen & " characters.", vbExclamation,
"Too long"
ctl.Text = Left(ctl.Text, iMaxLen)
ctl.SelStart = iMaxLen
End If
Exit_LimitChange:
Exit Sub
Err_LimitChange:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_LimitChange
End Sub
___________________________________________________________________
Any help will be appreciated.
Pete Provencher
with a single character I want it to tab to the next field (SearchTMS). I
have the following settings:
CurrentAbstractor
AutoTab = Yes
Tab Stop = Yes
Tab Index = 0
SearchTMS
AutoTab = No
Tab Stop = Yes
Tab Index = 1
To set the length of CurrentAbstractor I use the following
Private Sub CurrentAbstractor_KeyPress(KeyAscii As Integer)
Call LimitKeyPress(Me.CurrentAbstractor, 1, KeyAscii)
End Sub
_________________________________________________
Private Sub CurrentAbstractor_Change()
Call LimitChange(Me.CurrentAbstractor, 1)
End Sub
_________________________________________________
Sub LimitKeyPress(ctl As Control, iMaxLen As Integer, KeyAscii As Integer)
On Error GoTo Err_LimitKeyPress
' Purpose: Limit the text in an unbound text box/combo.
' Usage: In the control's KeyPress event procedure:
' Call LimitKeyPress(Me.MyTextBox, 12, KeyAscii)
' Note: Requires LimitChange() in control's Change event also.
If Len(ctl.Text) - ctl.SelLength >= iMaxLen Then
If KeyAscii <> vbKeyBack Then
KeyAscii = 0
Beep
End If
End If
Exit_LimitKeyPress:
Exit Sub
Err_LimitKeyPress:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_LimitKeyPress
End Sub
____________________________________________________
Sub LimitChange(ctl As Control, iMaxLen As Integer)
On Error GoTo Err_LimitChange
' Purpose: Limit the text in an unbound text box/combo.
' Usage: In the control's Change event procedure:
' Call LimitChange(Me.MyTextBox, 12)
' Note: Requires LimitKeyPress() in control's KeyPress event also.
If Len(ctl.Text) > iMaxLen Then
MsgBox "Truncated to " & iMaxLen & " characters.", vbExclamation,
"Too long"
ctl.Text = Left(ctl.Text, iMaxLen)
ctl.SelStart = iMaxLen
End If
Exit_LimitChange:
Exit Sub
Err_LimitChange:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_LimitChange
End Sub
___________________________________________________________________
Any help will be appreciated.
Pete Provencher