Setfocus on subform on tabbed form


H

Hugh self taught

Hi Access Gurus,

I have a tabbed main form which has 2 subforms on one of the tabs where the
subforms have been made to look like one form. My problem is that the user
needs to be able to tab through the first subform into the next seemlessly
but I can't get the setfocus syntax for that right in this setup.

The Mainform is "MainMenu" the TabControl is "TabCtl0" the Page is "Addr" &
the Subform is BusAddr. Can anyone help with the syntax? My intention is to
place it in the Lostfocus Event of the last field on the first subform.

Cheers for now
 
Ad

Advertisements

M

Marshall Barton

Hugh said:
I have a tabbed main form which has 2 subforms on one of the tabs where the
subforms have been made to look like one form. My problem is that the user
needs to be able to tab through the first subform into the next seemlessly
but I can't get the setfocus syntax for that right in this setup.

The Mainform is "MainMenu" the TabControl is "TabCtl0" the Page is "Addr" &
the Subform is BusAddr. Can anyone help with the syntax? My intention is to
place it in the Lostfocus Event of the last field on the first subform.


Not clear which subform is which.

Try this kind of code:

With Parent.subformcontrol2
.Form.Recordset.MoveFirst
.SetFocus
.Form.firstcontrol.SetFocus
End With

Note that the tab control nor its pages have anything to do
with it.
 
J

John W. Vinson

Hi Access Gurus,

I have a tabbed main form which has 2 subforms on one of the tabs where the
subforms have been made to look like one form. My problem is that the user
needs to be able to tab through the first subform into the next seemlessly
but I can't get the setfocus syntax for that right in this setup.

The Mainform is "MainMenu" the TabControl is "TabCtl0" the Page is "Addr" &
the Subform is BusAddr. Can anyone help with the syntax? My intention is to
place it in the Lostfocus Event of the last field on the first subform.

Cheers for now

The tab control is irrelevant: the syntax for referencing a subform is
identical, regardless of whether there is a tab control involved or not.

The simplest way is to add one more control in the first subform - you can
make it a tiny textbox, and hide it behind some other control. Make it last in
the Tab Index. In its GotFocus event (which will fire when the user tabs out
of the previous control, but not when they mouseclick back to some other
control to correct an error), use code like

Parent!BusAddr.SetFocus
Parent!BusAddr.Form!FirstControlOnSubform.Setfocus

to set focus, first to the other subform, and then to the first control in
that form's tab order.
 
Ad

Advertisements

H

Hugh self taught

Thanks John & Marshall,

You've both been such a help time & time again.

I didn't realize that I needed to break it down into 2 steps & couldn't
understand why I couldn't move the focus.

Many thanks
 

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