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

Why is SetFocus not working?

Status
Not open for further replies.

lwilly

Technical User
Apr 11, 2000
84
US
I am trying to set the focus to a control depending on user input. I am using me.controlname.setfocus to do this but it is not working. Any ideas?

Thank you
 
What kind of control is it?
Make sure the TAB stop is true and it has a TAB value too.


DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
The control is a text box, with both a tab stop set to yes and with a tab index.
 
Well, I just tried something out, just for kicks, and I got this to work.

I created a Combo box and here are some of the properties I set:
Record Source Type = Value List
Row Source = "FName";"First Name";"LName";"Last Name";"EmpID";"Employee ID"
Bound Column = 1
Column Count (Listed under "Format", not "Data") = 2

Then, in the On Change event, I put this code:
Private Sub Combo6_Change()
Me.Controls(Combo6.Column(0)).SetFocus
End Sub

I guess, all you really need to know is this:
To set the focus of a control, that you have the name of (as a string) just put:

Me.Controls(control's name).SetFocus

I just kinda went a step beyond. Also, with the ComboBox version, you eliminate the problem of accidentally typed incorrect control names, and can choose "User Friendly" control names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top