subform - tab back to main form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I make it so that when you press tab from the last record on a (continuous) subform, focus will exit the subform and continue to the next tab control on the main form

Many thanks

M
 
Hi Mikey,

How do you determine what is the "last record"? If the subform allows you to
enter new records then you need some way of determining what record is the
last record.

Regardless, a simple (built-in) method is to use Ctl-Tab instead of Tab.
This will set focus out of the subform and back to the main form.
 
Simplest way is to use Control+Tab to move to the next control on the main
form.

Otherwise, you will need some code to do this. Since you need to detect if
this is the "LAST" record and if you are exiting the "LAST" Control.

What I might do
- add an unbound control to your continuous form.
- make it the last control in the tab order
- set its size to 0 by 0 (or as close as you can get)
- use its on focus event to detect if this is the "Last Record" and if so
set the focus programatically to the "next" control on the main form

UNTESTED AIR CODE

Private Sub AutoTabControl_GotFocus()
If Me.RecordSetClone.RecordCount = Me.RecordsetClone.AbsolutePosition +1
Me.Parent.ControlName.SetFocus
End If
End Sub

That MAY have problems with a new record, so you might also need to test for
that condition. Something like the following.
If Me.NewRecord = True then
'Do what you wish
ElseIf Me.RecordSetClone.RecordCount ...
'Set focus where you wish
End if


Mikey said:
How can I make it so that when you press tab from the last record on a
(continuous) subform, focus will exit the subform and continue to the next
tab control on the main form?
 
Many thanks, your code helped a lot John. (although I could not get recordsetclone absolute position in line with the actual record - so I went round the issue)

There were no additions allowed on my form

What I did was look at the question number (the last q is always 32) and on the lost focus bit of my control, it moves to the main form if question number = 32

Thanks loads both of you



----- John Spencer wrote: ----

Simplest way is to use Control+Tab to move to the next control on the mai
form

Otherwise, you will need some code to do this. Since you need to detect i
this is the "LAST" record and if you are exiting the "LAST" Control

What I might d
- add an unbound control to your continuous form
- make it the last control in the tab orde
- set its size to 0 by 0 (or as close as you can get
- use its on focus event to detect if this is the "Last Record" and if s
set the focus programatically to the "next" control on the main for

UNTESTED AIR COD

Private Sub AutoTabControl_GotFocus(
If Me.RecordSetClone.RecordCount = Me.RecordsetClone.AbsolutePosition +
Me.Parent.ControlName.SetFocu
End I
End Su

That MAY have problems with a new record, so you might also need to test fo
that condition. Something like the following
If Me.NewRecord = True the
'Do what you wis
ElseIf Me.RecordSetClone.RecordCount ..
'Set focus where you wis
End i


Mikey said:
How can I make it so that when you press tab from the last record on
(continuous) subform, focus will exit the subform and continue to the nex
tab control on the main form
 
Back
Top