Setting Focus in a Subform control upon entry of the subform (1 Viewer)

sierra467

Registered User.
Local time
Today, 04:52
Joined
Aug 1, 2005
Messages
66
My main form is frmPatient and the subfrom is sfrmSurgeryInfo.

I want to make it that when the tab key is pressed in cboEmail in the frmPatient, that the cboSurgeryType control gets focus in sfrmSurgeryInfo.

Right now when the tab key is pressed, the focus in the sfrmSurgeryInfo is somehow set to last control that was edited when the sfrmSurgeryInfo form was active.

Can someone help please.
 

RuralGuy

AWF VIP
Local time
Today, 02:52
Joined
Jul 2, 2005
Messages
13,826
Forms displayed as SubForms have a tab order as well. Do you have yours set the way you want?
 

sierra467

Registered User.
Local time
Today, 04:52
Joined
Aug 1, 2005
Messages
66
Forms displayed as SubForms have a tab order as well. Do you have yours set the way you want?

Yes, that is what I thought too. I do have the SubForm tab order the way I want - cboSurgeryType is the first control in that subform and its TabOrder is set to the top of the list. The funny thing is that when the SubForm is reentered (on the same record in the main form or on another record in the main form), the focus seems to still stay at its last used location and not reset to the cboSurgeryType.

I tried putting Me.cboSurgeryType.SetFocus in the GotFocus of the subform but that did not work and I thought that maybe the form just needed to be refreshed so I tried the Compact and Repair Database... to see if that would help but nothing changed.

Any suggestions?
 

RuralGuy

AWF VIP
Local time
Today, 02:52
Joined
Jul 2, 2005
Messages
13,826
Hmmm... You are correct. Sorry, but I'm out of ideas! I tried it unsuccessfully on one of my subforms. Maybe someone else will drop by with a solution for you.
 

boblarson

Smeghead
Local time
Today, 01:52
Joined
Jan 12, 2001
Messages
32,059
In the On Current event of the SUBFORM put
Code:
Me.cboSurgeryType.SetFocus
 

RuralGuy

AWF VIP
Local time
Today, 02:52
Joined
Jul 2, 2005
Messages
13,826
Hi Bob. Does that work if you tab into the SubForm? In my test it didn't unless I put the cursor in the SubForm.
 

sierra467

Registered User.
Local time
Today, 04:52
Joined
Aug 1, 2005
Messages
66
Thanks for the help RR now and in the past.

boblarson, I tried that and it did nothing as well, thanks again any how.

Anyone else have any suggestions?
 

uncle-lai

Registered User.
Local time
Today, 01:52
Joined
Aug 8, 2003
Messages
98
Have you tried put it in the On Enter event of the child form?
 

boblarson

Smeghead
Local time
Today, 01:52
Joined
Jan 12, 2001
Messages
32,059
It worked for me on my A2K test database. I put it on the subform's on current control and then whenever I left the focus on a different control (although I used the subform in datasheet mode, so maybe that was the difference) it would be back whenever I went to a new main record and then tabbed to the subform.
 

sierra467

Registered User.
Local time
Today, 04:52
Joined
Aug 1, 2005
Messages
66
I did try the On Enter event too and still nothing. Thanks for all your help.

Could it be that the form is corrupt? Would I need to re make the entire form - I hope not. It should just work! Urgg!
 

boblarson

Smeghead
Local time
Today, 01:52
Joined
Jan 12, 2001
Messages
32,059
Can you either post the database or email it? I would like to see what is going on. Which version of Access are you using?
 

Charmed7

Registered User.
Local time
Today, 01:52
Joined
Jul 23, 2004
Messages
53
I have a form that has a main form on page 1, then a subform with another subform on page 2. On the last field of each form -> subform -> subform, I have a macro that says "GoToControl" and put the control. I don't know if that's helpful or not. Good Luck
 

sierra467

Registered User.
Local time
Today, 04:52
Joined
Aug 1, 2005
Messages
66
Workaround / Solution

Thank you for all your help. My final solution (not really exactly what I wanted) was to add the following line in the Exit Event of the last control in the Main form.
Code:
Me!sfrmSurgeryInfo.Form!cboSurgery.SetFocus
This allows the user to tab out of the main form and into the first control (cboSurgery) of the subform.

I was also having trouble with my exclamation points (!) and periods (.), but found this neat site that seemed to help. Hope it helps others that see this post.

http://www.mvps.org/access/forms/frm0031.htm

Thanks again for all your help and interest in solving my problem! It helped a lot.
 

Users who are viewing this thread

Top Bottom