Subform to subform navigation

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.
 
Create a tiny .0001 x .0001 textbox and put it as the last control in the
tab order of the subform. The control should have its visible property set
to true so that it can receive the focus. Since it is so tiny it won't be
seen. Then in the Gotfocus event of this control you can setfocus to the
other subform then to the first control on the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub
 
My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control in the
tab order of the subform. The control should have its visible property set
to true so that it can receive the focus. Since it is so tiny it won't be
seen. Then in the Gotfocus event of this control you can setfocus to the
other subform then to the first control on the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.
 
Possibly - I'd take it out of the current event of the first subform - it
really doesn't belong there at all. What happens after you remove it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.
 
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
-----Original Message-----
Possibly - I'd take it out of the current event of the first subform - it
really doesn't belong there at all. What happens after you remove it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.
 
Interesting, this code doesn't look like it should interfere. Do you have
any code in the OnEnter event of the second subform or any event code in the
second subform?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
-----Original Message-----
Possibly - I'd take it out of the current event of the first subform - it
really doesn't belong there at all. What happens after you remove it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.
 
I have a command button for inserting hyperlinks on the
2nd subform:
Private Sub cmdHyperlink_Click()
On Error GoTo Errhandler

Documents.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
Exit Sub

Errhandler:

Select Case Err
Case 2046
'Command not available
MsgBox "You must select an OLE field before running
this procedure.", vbCritical, "Not Available"
Case 2501
'Cancel selected in dialog box - do nothing
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select

End Sub
-----Original Message-----
Interesting, this code doesn't look like it should interfere. Do you have
any code in the OnEnter event of the second subform or any event code in the
second subform?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
-----Original Message-----
Possibly - I'd take it out of the current event of the first subform - it
really doesn't belong there at all. What happens after you remove it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


(e-mail address removed) wrote:
My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.

.
 
No events on the control ResponsibleParty? What are the properties of this
control? Is it enabled? It sounds like something is interfering with your
attempt to setfocus there but I'm not sure what it might be.

Try setting focus to a different control and see what happens. Also, just
for a baseline make sure that you can go directly from the main form to this
control on the subform by clicking with the mouse. Also verify that there
are no OnEnter or OnExit procedures for the subforms themselves.

Last but not least, did you try commenting out all the code except the code
on the first subform that takes you to the second subform? This should also
be helpful in isolating the problem. One other thing to try is to step
through the code using the debugger. Start from the code on the first
subform and set a breakpoint. Then step through the code and you will see
all the VBA that is executed as a result of setting focus away from the
first subform.

Let me know what happens when you try these things and if you're still stuck
we'll try something else :-)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a command button for inserting hyperlinks on the
2nd subform:
Private Sub cmdHyperlink_Click()
On Error GoTo Errhandler

Documents.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
Exit Sub

Errhandler:

Select Case Err
Case 2046
'Command not available
MsgBox "You must select an OLE field before running
this procedure.", vbCritical, "Not Available"
Case 2501
'Cancel selected in dialog box - do nothing
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select

End Sub
-----Original Message-----
Interesting, this code doesn't look like it should interfere. Do you have
any code in the OnEnter event of the second subform or any event code in the
second subform?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit

-----Original Message-----
Possibly - I'd take it out of the current event of the first subform -
it really doesn't belong there at all. What happens after you remove
it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


(e-mail address removed) wrote:
My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.

.
 
Ok, I commented out the follwing code from my 1st subform:
Private Sub frmNDA_details2_Enter()
'Forms!frmNDA_data5!frmNDA_details2.Requery
End Sub
And now I'm not stuck in my 2nd subform. This code appears
to be redundant and does not seem to have adversely
affected/broken anything else so I'm taking it out.
Thanks for all your help.
-----Original Message-----
No events on the control ResponsibleParty? What are the properties of this
control? Is it enabled? It sounds like something is interfering with your
attempt to setfocus there but I'm not sure what it might be.

Try setting focus to a different control and see what happens. Also, just
for a baseline make sure that you can go directly from the main form to this
control on the subform by clicking with the mouse. Also verify that there
are no OnEnter or OnExit procedures for the subforms themselves.

Last but not least, did you try commenting out all the code except the code
on the first subform that takes you to the second subform? This should also
be helpful in isolating the problem. One other thing to try is to step
through the code using the debugger. Start from the code on the first
subform and set a breakpoint. Then step through the code and you will see
all the VBA that is executed as a result of setting focus away from the
first subform.

Let me know what happens when you try these things and if you're still stuck
we'll try something else :-)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a command button for inserting hyperlinks on the
2nd subform:
Private Sub cmdHyperlink_Click()
On Error GoTo Errhandler

Documents.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
Exit Sub

Errhandler:

Select Case Err
Case 2046
'Command not available
MsgBox "You must select an OLE field before running
this procedure.", vbCritical, "Not Available"
Case 2501
'Cancel selected in dialog box - do nothing
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select

End Sub
-----Original Message-----
Interesting, this code doesn't look like it should interfere. Do you have
any code in the OnEnter event of the second subform or any event code in the
second subform?

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

cs wrote:
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit

-----Original Message-----
Possibly - I'd take it out of the current event of the first subform -
it really doesn't belong there at all. What happens after you remove
it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


(e-mail address removed) wrote:
My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus
Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last control
in the tab order of the subform. The control should have its visible
property set to true so that it can receive the focus. Since it is
so tiny it won't be seen. Then in the Gotfocus event of this control
you can setfocus to the other subform then to the first control on
the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.

.

.
 
No problem, glad you found the problem :-)

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Ok, I commented out the follwing code from my 1st subform:
Private Sub frmNDA_details2_Enter()
'Forms!frmNDA_data5!frmNDA_details2.Requery
End Sub
And now I'm not stuck in my 2nd subform. This code appears
to be redundant and does not seem to have adversely
affected/broken anything else so I'm taking it out.
Thanks for all your help.
-----Original Message-----
No events on the control ResponsibleParty? What are the properties
of this control? Is it enabled? It sounds like something is
interfering with your attempt to setfocus there but I'm not sure
what it might be.

Try setting focus to a different control and see what happens. Also,
just for a baseline make sure that you can go directly from the main
form to this control on the subform by clicking with the mouse. Also
verify that there are no OnEnter or OnExit procedures for the
subforms themselves.

Last but not least, did you try commenting out all the code except
the code on the first subform that takes you to the second subform?
This should also be helpful in isolating the problem. One other
thing to try is to step through the code using the debugger. Start
from the code on the first subform and set a breakpoint. Then step
through the code and you will see all the VBA that is executed as a
result of setting focus away from the first subform.

Let me know what happens when you try these things and if you're
still stuck we'll try something else :-)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a command button for inserting hyperlinks on the
2nd subform:
Private Sub cmdHyperlink_Click()
On Error GoTo Errhandler

Documents.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
Exit Sub

Errhandler:

Select Case Err
Case 2046
'Command not available
MsgBox "You must select an OLE field before running
this procedure.", vbCritical, "Not Available"
Case 2501
'Cancel selected in dialog box - do nothing
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select

End Sub
-----Original Message-----
Interesting, this code doesn't look like it should interfere. Do
you have any code in the OnEnter event of the second subform or
any event code in the second subform?

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

cs wrote:
Sorry the code that's on the OnCurrent event of the first
subform is there to display details in the 2nd subform
about the record that is selected in the first subform:

Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![frmNDA_details3].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit

-----Original Message-----
Possibly - I'd take it out of the current event of the first
subform - it really doesn't belong there at all. What happens
after you remove it?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


(e-mail address removed) wrote:
My Code:
Private Sub txtGoToSfrm_GotFocus()
Me.Parent.frmNDA_details3.SetFocus

Me.Parent.frmNDA_details3.Form.ResponsibleParty.SetFocus
End Sub
It takes me to the second subform but then I'm stuck there!
I can't even click in the main form or the first subform.
I also have the following code in the first subforms
OnCurrent event so that it will call the appropriate
record in the second subform. Are the 2 clashing ?
thanks for the help.
-----Original Message-----
Create a tiny .0001 x .0001 textbox and put it as the last
control in the tab order of the subform. The control should
have its visible property set to true so that it can receive
the focus. Since it is so tiny it won't be seen. Then in the
Gotfocus event of this control you can setfocus to the other
subform then to the first control on the second subform.

Private Sub Text20_GotFocus()
Me.Parent.subform2.SetFocus
Me.Parent.subform2.Form.Text1.SetFocus
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


cs wrote:
I have a form(DocHistory) with 2 subforms. The first
subform is a continuous form with cycling set to current
record. What code can I use so that when I tab from the
last control in subform1 it goes to the first control in
subform2. Thanks for any help you can provide.


.


.

.

.
 
Back
Top