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

SelStart of Controls

Status
Not open for further replies.

uncchcs

Programmer
Jun 4, 2002
13
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top