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!

ComboBox.SetFocus 2

Status
Not open for further replies.

jasek78

Programmer
Nov 5, 2001
298
US
I have an MDI application and on one form, I execute some commands on form_load, and then I want to set the focus to the combo box.

I've tried using cboDate.SetFocus but I get a RunTime error '5': "Invalid Procedure call or argument"



 
What you might want to do is put the setfocus command inside of the form_paint() event.

Martin I don't suffer from insanity.
I enjoy every minute of it.
 
Actually come to think of it, that will reset the focus every time you come back to that window...

if you only want it to set the focus when it first pops up, then set the object's tab order to 0


Martin I don't suffer from insanity.
I enjoy every minute of it.
 
or...

Code:
Private Sub Form_Load()

  ' do whatever you need here!
  
  Show ' display the form first
  cboDate.SetFocus ' this should now work
End Sub
 
yes you can if you call the Show method of the form before calling the SetFocus method of a control on that form
 
wow, this thread got nailed right after I left work for the weekend. I will call the Show method, then call SetFocus on the combo. Thanks for the help!

jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top