Moving between subforms

C

carlhu

I down loaded the Contact Management 2003 template. On the calls tab there
are two sub forms, when you tab or enter out of the subject field I want the
focus in the notes text box not making a new record.
 
K

kingston via AccessMonster.com

Go into the (sub)form's design view. In the (sub)form's properties, change
the Cycle property from All Records to Current Record or Current Page.
 
C

carlhu

Sorry neither worked still cycling fron date, time, subject & back to date.
you have to click in the note box on the 2nd subform to get it there.
 
K

kingston via AccessMonster.com

You can change the tab order for every control. Just go into the control's
properties and change the numbers to your desired sequence. You can even
prevent a control from being part of the tab chain. My first comment was to
prevent a new record from occuring.
 
C

carlhu

Yes I know that but you cannot add a subforms control to the forms tab order,
or can u???
I want to enter at the [date] field tab to [time] tab to [subject] (on one
sub form) and on the after update trigger of [subject] set focus to notes (
on a different sub form) I have spent 8 days on this one issue, with tab
orders & setfocus & gotocontrol, but I am obviously not using the correct
syntax as access returns no such control errors. So I'm figuring I'm on sub
form telling it to go to a control on another subform but access is telling
me that it cannot see the control from where it's looking from. So how do I
tell access to look outside the box it's in?
 
K

kingston via AccessMonster.com

Yes, a subform is just another control. So it is part of a form's tab order.

However, your problem is different because tab order affects only controls
within the form itself. It appears that you have one main form with two
subforms. One subform does not know the other subform exists when it comes
to tab order. You'll have to write some code to do what you want.

In your main form, create a public procedure. For example, call it Move2Sub2:


Public Sub Move2Sub2()

DoCmd.GoToControl Me.SubForm2.Name
DoCmd.GoToControl "ControlOnSubForm2"

End Sub

SubForm2 is your second subform's control name in as referenced by the main
form.
Next, attach a procedure to the After Update event of the last control in
your first subform:

Forms!MainForm.Move2Sub2

MainForm is the name of your main form. You can choose a more appropriate
event if you don't want to use After Update.
Yes I know that but you cannot add a subforms control to the forms tab order,
or can u???
I want to enter at the [date] field tab to [time] tab to [subject] (on one
sub form) and on the after update trigger of [subject] set focus to notes (
on a different sub form) I have spent 8 days on this one issue, with tab
orders & setfocus & gotocontrol, but I am obviously not using the correct
syntax as access returns no such control errors. So I'm figuring I'm on sub
form telling it to go to a control on another subform but access is telling
me that it cannot see the control from where it's looking from. So how do I
tell access to look outside the box it's in?
You can change the tab order for every control. Just go into the control's
properties and change the numbers to your desired sequence. You can even
[quoted text clipped - 10 lines]
 
C

carlhu

Thank you, it might have worked but I just noticed the two sub forms are on a
page of a tab control and I keep getting the error "Cannot find form 'Calls'
". I guess I should start my own & not try to fix someone elses.

kingston via AccessMonster.com said:
Yes, a subform is just another control. So it is part of a form's tab order.

However, your problem is different because tab order affects only controls
within the form itself. It appears that you have one main form with two
subforms. One subform does not know the other subform exists when it comes
to tab order. You'll have to write some code to do what you want.

In your main form, create a public procedure. For example, call it Move2Sub2:


Public Sub Move2Sub2()

DoCmd.GoToControl Me.SubForm2.Name
DoCmd.GoToControl "ControlOnSubForm2"

End Sub

SubForm2 is your second subform's control name in as referenced by the main
form.
Next, attach a procedure to the After Update event of the last control in
your first subform:

Forms!MainForm.Move2Sub2

MainForm is the name of your main form. You can choose a more appropriate
event if you don't want to use After Update.
Yes I know that but you cannot add a subforms control to the forms tab order,
or can u???
I want to enter at the [date] field tab to [time] tab to [subject] (on one
sub form) and on the after update trigger of [subject] set focus to notes (
on a different sub form) I have spent 8 days on this one issue, with tab
orders & setfocus & gotocontrol, but I am obviously not using the correct
syntax as access returns no such control errors. So I'm figuring I'm on sub
form telling it to go to a control on another subform but access is telling
me that it cannot see the control from where it's looking from. So how do I
tell access to look outside the box it's in?
You can change the tab order for every control. Just go into the control's
properties and change the numbers to your desired sequence. You can even
[quoted text clipped - 10 lines]
are two sub forms, when you tab or enter out of the subject field I want the
focus in the notes text box not making a new record.
 
C

carlhu

Just in case anyone is interested I found a way of doing it...

Private Sub Subject_AfterUpdate()

Dim record As Long 'the current record
of the call listing

record = Forms![Contacts].Form![Call Listing Subform].Form.CurrentRecord

If record <= 1 Then ' this covers the case when on first call

DoCmd.GoToRecord , , acNewRec

DoCmd.GoToRecord , , acFirst



Else ' covers
case on all other calls

DoCmd.GoToRecord , , acNewRec ' now goto new record

DoCmd.GoToRecord , , acGoTo, record ' goto the current record

End If

' the above means that after leaving the subject field the current
record remains the same

Forms![Contacts].Form![Call Details Subform].SetFocus
' move the focus
to the details subforms

DoCmd.GoToControl ("Notes") ' now ensure the Notes field is
selected

End Sub



carlhu said:
Thank you, it might have worked but I just noticed the two sub forms are on a
page of a tab control and I keep getting the error "Cannot find form 'Calls'
". I guess I should start my own & not try to fix someone elses.

kingston via AccessMonster.com said:
Yes, a subform is just another control. So it is part of a form's tab order.

However, your problem is different because tab order affects only controls
within the form itself. It appears that you have one main form with two
subforms. One subform does not know the other subform exists when it comes
to tab order. You'll have to write some code to do what you want.

In your main form, create a public procedure. For example, call it Move2Sub2:


Public Sub Move2Sub2()

DoCmd.GoToControl Me.SubForm2.Name
DoCmd.GoToControl "ControlOnSubForm2"

End Sub

SubForm2 is your second subform's control name in as referenced by the main
form.
Next, attach a procedure to the After Update event of the last control in
your first subform:

Forms!MainForm.Move2Sub2

MainForm is the name of your main form. You can choose a more appropriate
event if you don't want to use After Update.
Yes I know that but you cannot add a subforms control to the forms tab order,
or can u???
I want to enter at the [date] field tab to [time] tab to [subject] (on one
sub form) and on the after update trigger of [subject] set focus to notes (
on a different sub form) I have spent 8 days on this one issue, with tab
orders & setfocus & gotocontrol, but I am obviously not using the correct
syntax as access returns no such control errors. So I'm figuring I'm on sub
form telling it to go to a control on another subform but access is telling
me that it cannot see the control from where it's looking from. So how do I
tell access to look outside the box it's in?

You can change the tab order for every control. Just go into the control's
properties and change the numbers to your desired sequence. You can even
[quoted text clipped - 10 lines]
are two sub forms, when you tab or enter out of the subject field I want the
focus in the notes text box not making a new record.
 

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