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!

Passing focus between subform controls.

Status
Not open for further replies.

EMSaddict

Technical User
Oct 9, 2001
3
CA
I have a main form with a subform that contains three more subforms.
(MainForm (SubForm (SubSubForm1, SubSubForm2, SubSubForm3)))
And of course each form and subform has many controls. I have control of the navigation until I want to leave SubSubForm1 and give focus to a control on SubSubForm2. I have searched through just about all the posts and thought I had the fix a few times, but I keep getting an error because the syntax I am using is wrong.
Names of my forms are as follows:
MainForm = fmTrip
SubForm = frmPatient
SubSubForm1 = sbfrmComplaint
SubSubForm2 = sbfrmSpecialCoding
SubSubForm3 = sbfrmProtocol

I want to give the combobox "cbxSpecialCoding" on subform "sbfrmSpecialCoding" focus, after leaving the control "cbxChiefComplaint" on the subform "sbfrmComplaint"
I hope that I explained what I need to do and that this makes sense.

Thanks in advance for any help,
Cheers!
 
Hi,

I hope I understand what do you need,
you can write On cbxChiefComplaint_Exit
Forms![fmTrip]![sbfrmSpecialCoding].SetFocus
Then
In the Main Form ,,,,For then sbfrmSpecialCoding Subform,,,,On Enter Event
[sbfrmSpecialCoding].Form![cbxSpecialCoding].SetFocus
And the same from this subform to the next

If any more help let me know.

Good Luck
 
Add this code in the On Exit event of the cbxChiefComplaint control:

Parent.SetFocus
Parent!sbfrmSpecialCoding.Form.SetFocus
Parent!sbfrmSpecialCoding.Form.cbxSpecialCoding.SetFocus

This will set the focus from the control to the Parent form (frmPatient), then from that form to the required subform (sbfrmSpecialCoding), and then to the control (cbxSpecialCoding).

Have a read of the following topics in the Access Help file for more info:

Parent Property
Me property
SubForms -> Referring to Associated form in Visual Basic


HTH

Lightning
 
Haitham,

Thank you for the response, and you understood exactly what I meant. I ended up setting the focus to the sbfrmSpecialCoding and letting the tab order do the rest. I like your suggested way of doing it and I think I'll go back and change it. I am learning that coding has to go step by step, and I was trying to skip one.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top