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

Changing the focus on a form

Status
Not open for further replies.

hdgirl

Technical User
Feb 2, 2002
131
GB
I have a form with a command button that has the focus when the form opens, how can i change it so that a combo box on the same form gets the focus on opening?

CJB
 
Set the Index property of your controls in the order that you want them to get the focus, starting with 0, then 1 etc.

0 will get the focus when the form opens.

Bill
 
Or, on the form open event, just type

Controlname.SetFocus
 
Hi,
Open the form in the design veiw and select the OnOpen Event of the Form and type the following between the lines

Me.YourComboName.SetFocus

Note: May be your CommandButton has focus already set on the OnOpenEvent. You have to change it.
When you finish your code will be look like below. Make sure to change "YourComboName" to name of your ComboBox.

<-------------*****----------->
Private Sub Form_Open(Cancel As Integer)

Me.YourComboName.SetFocus

End Sub
<-------------*****----------->

BillPower has given another solution.

ZmrAbdulla
 
Thanks to JonoB that worked a treat and thanks to all the others that replied

CJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top