I have a form that has 25 controls each of which are textboxes or combo boxes. What I am trying to do is set the SelStart of each control equal to the SelLength. What I have done so far is to set the SelStart = to the SelLength on the Enter event for each control.
For example:
Private Sub myTextBox_Enter()
Me.myTextBox.SelStart = Me.SelLength
End Sub
What I would like to do is through one procedure set this for all controls without having to go through each control's enter event.
I tried:
Private Sub ControlSelStart()
Dim ctl As Control
For Each ctl in Me.Controls
With ctl
Select Case .ControlType
Case acTextBox
.SelStart = .SelLength
Case acComboBox
.SelStart = .SelLength
End Select
End With
Next ctl
End Sub
Then I called procedure from the Form_Load event, but I got an error stating that I couldn't set the properties for control that didn't have the focus.
Is there a way to set this property each time any of the controls enter event is fired?
Jason
For example:
Private Sub myTextBox_Enter()
Me.myTextBox.SelStart = Me.SelLength
End Sub
What I would like to do is through one procedure set this for all controls without having to go through each control's enter event.
I tried:
Private Sub ControlSelStart()
Dim ctl As Control
For Each ctl in Me.Controls
With ctl
Select Case .ControlType
Case acTextBox
.SelStart = .SelLength
Case acComboBox
.SelStart = .SelLength
End Select
End With
Next ctl
End Sub
Then I called procedure from the Form_Load event, but I got an error stating that I couldn't set the properties for control that didn't have the focus.
Is there a way to set this property each time any of the controls enter event is fired?
Jason