Set Focus Tabbed Subform

  • Thread starter Terry B via AccessMonster.com
  • Start date
T

Terry B via AccessMonster.com

I have a Main form named frmContracts.
It contains a Tab Control named TabMain.
One of these tabs contains a subform named (frmformwork) which is also a
tabbed control.
My problem is that when I click on the Mainform tab control named Formwork,
the subform
is displayed however it does not seem to have focus. All of the checkboxes
are grayed out.
If I click on any one of the tabs or a field on the subform it wakes up and
everything works fine.

1. Can I set focus in the subform on my first tabbed sheet named Decks?
I Dont really care if a particular field has focus I just dont want it to be
dead until you
click something.

2. Where should I put the event procedure.

I tried using the Onclick event for the Main forms Tab called Formwork,
and making one if the fields in my subform have focus, but Im obviously doing
it wrong.

Me.TabMain.SetFocus
Me.frmFormwork.Form.LangFId.SetFocus
 
W

Wayne Morgan

I recently went through this with someone else. There appears to be a bug in
the tab control. We came up with two work-arounds.

1) Change the style of the tab control to No Tabs. Use buttons on the main
form to change between the various tabs. In the click event of the button
for the tab that has the subform, after changing to that tab, set focus to
the subform control. Setting focus to a subform control is a two step
procedure. You first have to set focus to the subform control on the main
form then set focus to the control on the subform.

2) After clicking on the desired tab and setting focus to the desired
control (see note above about the two step procedure) we found that if you
moved the focus to another form then back again, that the focus would appear
properly on the subform. This was accomplished by opening a very small form
then closing it again. This moved the focus to the other form then, when it
closed, the focus moved back to the tab form and everything appeared normal.
 
J

Jim

Wayne,

Does this apply to what I am trying to do also?

I have a form with 2 tab controls. On one tab I have a subform that
contains equipment details on a second tab I have a subform that contains
summary counts/mins/max information about the equipment from the first tab.

When I click from tab 1 to tab 2 I want to requery some of the fields in the
subform but I cannot find an event that occurs when the second tab is clicked.

Thanks in advance,

Jim

Wayne Morgan said:
I recently went through this with someone else. There appears to be a bug in
the tab control. We came up with two work-arounds.

1) Change the style of the tab control to No Tabs. Use buttons on the main
form to change between the various tabs. In the click event of the button
for the tab that has the subform, after changing to that tab, set focus to
the subform control. Setting focus to a subform control is a two step
procedure. You first have to set focus to the subform control on the main
form then set focus to the control on the subform.

2) After clicking on the desired tab and setting focus to the desired
control (see note above about the two step procedure) we found that if you
moved the focus to another form then back again, that the focus would appear
properly on the subform. This was accomplished by opening a very small form
then closing it again. This moved the focus to the other form then, when it
closed, the focus moved back to the tab form and everything appeared normal.
 
W

Wayne Morgan

No, the problem was just with getting the focus to appear where desired. You
should be able to requery the desired controls. You would use the Change
event of the tab control. To refer to a control on a subform and requery it,
the syntax would be

Me.NameOfSubformControl.Form.NameOfControlOnSubform.Requery

For the syntax above, the subform is considered to be part of the main form,
not the tab control. The Subform Control is a container control that holds
the subform. This control is where you set the parent/child link fields. The
name of this control may or may not be the same as the name of the subform
itself.

--
Wayne Morgan
MS Access MVP


Jim said:
Wayne,

Does this apply to what I am trying to do also?

I have a form with 2 tab controls. On one tab I have a subform that
contains equipment details on a second tab I have a subform that contains
summary counts/mins/max information about the equipment from the first
tab.

When I click from tab 1 to tab 2 I want to requery some of the fields in
the
subform but I cannot find an event that occurs when the second tab is
clicked.

Thanks in advance,

Jim
 
J

Jim

Wayne,

Thanks it works. Just one thing - I have 3 fields on the subform that
dsum() three different fields in qry1 and while testing the .requery I
referenced only one of the fields in the OnChange event however, all 3 fields
are refreshed on the subform.

Should I add the other two fields to the OnChange event or just let it go?

Thanks again,

Jim
 
W

Wayne Morgan

If one of the calculated controls on the subform references the other, it
could cause a cascade like the one you are seeing. Calculated controls
usually don't need refreshed via code if their Control Source points to
another control on the same form and that other control gets changed.

However, if all you're wanting to do is update all of the calculated
controls on the subform, you may find issuing a ReCalc to the form will work
also.

Me.NameOfSubformControl.Form.ReCalc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top