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!

Form/subform focus 1

Status
Not open for further replies.

cgarmas

Technical User
Jun 16, 2005
37
US
I have a Main form with a subform1 which has a nested subform2. The main form has two unbound combo boxes and a bound text box, these forms are linked and well synchronized and movement between controls from form to subforms was fine until I added a command button on the first subform to open another form. When I open the form I retrieve a record in the main form and enter new records in the two subforms, up to this point everything is fine, but when I retrieve a new record in the main form the cursor jumps from the combo box to the last control in the second subform. I don't understand why adding the command button changed the behavior of focus between the forms and controls. I have tried several ways of setting the focus to a control in the first subform without any results. I'll appreciate any suggestions to resolve this problem.
 
setting the focus to a control in the first subform
you have to use a 2 steps procedure:
1) set the focus to the first subform control
2) set the focus to the control in the subform.
Example:
Forms![mainform]![subform1].SetFocus
Forms![mainform]![subform1].Form![control].SetFocus

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PH for the suggestion, I tried it from the unbound combo box on the LostFocus event, and I got the following message "you canceled the previous operation" I can't do it from the KeyDown of the combo box because this control uses two strikes of the enter key, one to set the value in the box and one to move to another control. I tried this also on the keyDown event of the bound control and it worked, but because I am hiding this control I would prefer to do it from the combo box.
 
Why not in the AfterUpdate event procedure of the combo ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have this code provided by TheAceMan1 in the AfterUpdate
Private Sub EnrollmentNumber_AfterUpdate()
Dim rst As DAO.Recordset, Criteria As String
Set rst = Me.RecordsetClone
Criteria = "[ClientID]='" & Me!Client_ID & "' AND " & _
"[EnrollNumber]='" & Me!EnrollmentNumber.Column(1) & "'"

rst.FindFirst Criteria
Me.Bookmark = rst.Bookmark
Set rst = Nothing

If is possible to put it here could you tell me in what part should I stick it in?
 
Just before the End Sub ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks a lot PH that worked, I had the same problem moving to the second subform, but I applied the same procedure and everything is working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top