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

Set Focus to a combo box

Status
Not open for further replies.

Wes98765

Programmer
Jul 31, 2002
135
US
How do I set focus to a combo box VB 6. You know when you click on a combo it is blue then the user can type ect. I can't get it to work and I can't find information on it.

Thanks

Wes
 
Once the form is loaded you can use this,

Code:
Combo1.SetFocus

zemp
 
Ok it works fine after the page is loaded. How would you suggest setting focus on the page load?
 
Place that syntax in the Form_Load function, and it should set the focus when the form is loaded.
 
Not in form_Load. This will give error 5 because the form and control (objects) don't really exist yet. They are in the process of being created. You can only set focus to an object that exists.

Try form_Activate.

zemp
 
If you want to set focus on the combo box everytime the form is loaded just set it's TabStop Property to 0.
 
I think bmdb means the TabIndex property to 0.
 
Zemp is right, use the Form_Activate event which will fire every time that the form gets focus from within the app.

However if you only want to set the focus when the form first loads, you can use SetFocus in the Load event as long as you call me.Show at the end of the Form_Load immediately before the SetFocus.
Code:
Private Sub Form_Load()
'do all your other bits first
'.
'.
Me.Show
Combo1.SetFocus
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top