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

Setting focus problem 1

Status
Not open for further replies.

delman333

Technical User
Oct 20, 2003
32
US
I have 9 groups of 4 comboboxes on the form...but at any given time there can only be one set of four enabled. I use GotFocus events on each set of four so that the user must enter data in the correct order of comboboxes. As the user enters data in the first enabled box...the focus automatically moves to the next appropriate enabled box. When data is selected in the last of the four boxes that group is disabled and the second set is enabled...and so on down the entire set of 9 groups.

However...I have an editing procedure command button that brings up a dialog box. If the user selects Yes to open the Group Edit Selection Form all the groups are disabled and the uer may select which group to edit...this also works fine. But if the user changes their mind and selects No to not open the form...I am having trouble returning the focus to the correct point where they left off.

This seemed like a simple problem at first...but my limited experience quickly ran out of ideas. Any suggestions would be greatly appreciated.
 
You could try saving the name of the control that the user was last on (based on GotFocus events) in a variable:

Dim strLastFocus as String

Private Sub cboField1_GotFocus()
strLastFocus = "cboField1"
End Sub

Then use the contents of the variable to set the focus again if the user selects "No":

Me(strLastFocus).SetFocus

Or, if you need to save the NEXT control the user was going to (it seems you are setting that now in each prior control's GotFocus event), save the control name that you will NEXT set focus to in the string variable.

[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
It's always the simple fixes that are so cool. It works great! Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top