LFMSupport
asked on
Setting Focus of a Control
Quick one. Is there anyway of setting the focus of a control held in a string.
e.g
Dim StrControlName as String
StrControlName.SetFocus
or
Set ActiveControl = StrControlName
The above 2 dont work obviously but is there any other way without using some fancy API?
I need this quick so theres 500 at stake!!
Thanks.
e.g
Dim StrControlName as String
StrControlName.SetFocus
or
Set ActiveControl = StrControlName
The above 2 dont work obviously but is there any other way without using some fancy API?
I need this quick so theres 500 at stake!!
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>Type mismatch error!
I could not reproduce a type mismatch, but only a "invalid procedure call", and that only when the form was not visible (fully loaded)...
I could not reproduce a type mismatch, but only a "invalid procedure call", and that only when the form was not visible (fully loaded)...
ASKER
Actually im getting "Object does not support this property or method" not type mismatch.
ASKER
Thats exaclty what im using:
Private Sub Test()
Dim str As String
str = "txtSecAddress"
Controls(str).SetFocus
End Sub
Private Sub Test()
Dim str As String
str = "txtSecAddress"
Controls(str).SetFocus
End Sub
>Object does not support this property or method
well, you might have a control that indeed does not support the SetFocus method, or is possibly disabled at the time you call the SetFocus method.
well, you might have a control that indeed does not support the SetFocus method, or is possibly disabled at the time you call the SetFocus method.
ASKER
Doh, that control is locked!!
Thanks for your help mate.
Thanks for your help mate.
ASKER
Type mismatch error!
I have found a suitable workaround but will still award points if answered correctly.
Workaround is to store TabIndex of control in a string then use ActiveControl.TabIndex = CInt(String)
Thanks.