Navigating Smoothly Between Main/Subforms

  • Thread starter Thread starter Kevin Sprinkel
  • Start date Start date
K

Kevin Sprinkel

What options are there to elegantly move from a main form
to an embedded subform, and on to the next subform or back
to the main form? Clicking with the mouse, taking the
user away from the keyboard, seems clunky. None of my
reference books seem to say anything about it.

Thanks for any assistance.
 
I'm able to just make sure it's Tab Order includes everything in the order it should, and set the Tab Stop property of all textboxes etc, that I want to hit to "True"
 
Thanks for responding.

Yes, this is good practice. But, within a subform, Tab
goes between its controls. Pressing Tab or Enter from the
last subform control opens up a new record, which is fine,
since, as its a multi-record form, the user might wish to
enter a new record. What I'm looking for is a smooth way
for the user to say, "I'm done here; let's move to the
next subform".

Do you have a good way of handling this situation?

Best regards.

Kevin Sprinkel
Becker && Frondorf
-----Original Message-----
I'm able to just make sure it's Tab Order includes
everything in the order it should, and set the Tab Stop
property of all textboxes etc, that I want to hit to "True"
 
Hi Kevin,

Teach users to use Ctl-Tab to navigate out of the subform.

Another way you can allow the user to tab through the subform controls back
to the main form is to create a decoy control on the subform. Make it .001 x
..001 and put it in the tab order after the last real control. Then in the
GotFocus event for the decoy control you setfocus back to the parent form.

Private Sub Text8_GotFocus()
Me.Parent.City.SetFocus
End Sub
 
Thanks, Sandra, for your response. I've wanted to avoid
<Ctrl>-Tab, since it's not intuitive. And I don't want to
automatically go to the next main form control after the
last subform control, because the user might want to add
another detail record.

In thinking about it last night, I decided that the
solution might be to move to the next main form control if
the user attempts to move off the first subform control
without entering a value, i.e., in pseudocode:

If Nz([subformcontrol)=0 Then Moveto Next Mainform Control

I got this to work last night, except that inexplicably
the cursor landed in the second control of the next
subform instead of the first. So I tried moving
explicitly to the first subform control, without success,
using:

Dim ctl as Control
Set ctl = Forms!MyMainForm!MySecondSubForm!firstsubformctl
DoCmd.GotoControl ctl.Name

Any idea where I'm going wrong?
 
Hi Kevin,

I know what you mean about it not being intuitive but . . . in my
experience, users who can't go beyond the intuitive keyboard actions also
tend to use the mouse for form navigation, no matter what I do or tell them
(it drives me crazy sometimes)!

First, I would avoid the Docmd.Gotocontrol method - I do not like docmd
methods for form navigation because they aren't as robust as the form and
control methods that do the same things (Setfocus for example).

If I understand you correctly you want to go from the first subform to the
first control on the second subform. To do this, you first have to setfocus
to the second subform control, then to the control on the second subform.
For example - this code in the Exit event of the Custid field on 'sfrm1'
will move focus to the Custid field on 'sfrm2'. The code is in sfrm1's class
module. Also, 'sfrm1' and 'sfrm2' are the names of the subform controls on
the main form (was not actually relevant in this example except that it is
where the code originates).

Private Sub Custid_Exit(Cancel As Integer)
If IsNull(Me.Custid) Then
Me.Parent.sfrm2.SetFocus
Me.Parent.sfrm2.Form.Custid.SetFocus
End If
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Kevin said:
Thanks, Sandra, for your response. I've wanted to avoid
<Ctrl>-Tab, since it's not intuitive. And I don't want to
automatically go to the next main form control after the
last subform control, because the user might want to add
another detail record.

In thinking about it last night, I decided that the
solution might be to move to the next main form control if
the user attempts to move off the first subform control
without entering a value, i.e., in pseudocode:

If Nz([subformcontrol)=0 Then Moveto Next Mainform Control

I got this to work last night, except that inexplicably
the cursor landed in the second control of the next
subform instead of the first. So I tried moving
explicitly to the first subform control, without success,
using:

Dim ctl as Control
Set ctl = Forms!MyMainForm!MySecondSubForm!firstsubformctl
DoCmd.GotoControl ctl.Name

Any idea where I'm going wrong?
Hi Kevin,

Teach users to use Ctl-Tab to navigate out of the subform.

Another way you can allow the user to tab through the subform
controls back to the main form is to create a decoy control on the
subform. Make it .001 x ..001 and put it in the tab order after the
last real control. Then in the GotFocus event for the decoy control
you setfocus back to the parent form.

Private Sub Text8_GotFocus()
Me.Parent.City.SetFocus
End Sub
 
Thanks for the advice re: Docmd, and the new code for
setting the focus the way I wish. I've tested it, and it
not only works, but feels right. Normally, my users will
be entering multiple records in the detail subforms, but
when they're done, they can keep in rhythm and simply hit
<Tab> or <Enter> to go on to the next.

Obviously, if they want to go back to the main form or
skip to a different subform from where they are, they can
still use <Ctrl>-<Tab> and <Ctrl>-<Shft>-<Tab>, so I will
teach them this. But for grunt data entry, this method
makes a smooth flow that I think they will appreciate.

Thanks for your help in getting it implemented.

Best regards.
Kevin Sprinkel
Becker & Frondorf

I know what you mean about it not being intuitive
but . . . in my experience, users who can't go beyond the
intuitive keyboard actions also tend to use the mouse for
form navigation, no matter what I do or tell them (it
drives me crazy sometimes)!

First, I would avoid the Docmd.Gotocontrol method - I do
not like docmd.methods for form navigation because they
aren't as robust as the form and control methods that do
the same things (Setfocus for example).

If I understand you correctly you want to go from the
first subform to the first control on the second subform.
To do this, you first have to setfocus to the second
subform control, then to the control on the second subform.
For example - this code in the Exit event of the Custid
field on 'sfrm1' will move focus to the Custid field
on 'sfrm2'. The code is in sfrm1's class module.

Also, 'sfrm1' and 'sfrm2' are the names of the subform
controls on the main form (was not actually relevant in
this example except that it is
 
What I'm looking for is a smooth way
for the user to say, "I'm done here; let's move to the
next subform".

Do you have a good way of handling this situation?

Without the mouse? Ctrl-Tab will tab out of the subform.
 
Back
Top