Moving from a form to a Nested Subform elsewhere on the form - Hel

E

efandango

I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"
 
M

Marshall Barton

efandango said:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"


The GoToControl line is resetting the focus back to the
first subform. Get rid of it.
 
E

efandango

Marshall,

I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]



Marshall Barton said:
efandango said:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"


The GoToControl line is resetting the focus back to the
first subform. Get rid of it.
 
M

Marshall Barton

How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?
--
Marsh
MVP [MS Access]

I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]

efandango said:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"


Marshall Barton said:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.
 
E

efandango

I think it because, as you say Windows should provide some visual cue, but
the cursor just highlights the data in my 'departue' text box (i'm using
d-click for the event), and the cursor doesn't go to the destination form
control. The reason I mentioned findng a record is because I was trying to
explain why i thought I needed the line: DoCmd.GoToControl "Joiner_Title_ID"
once I was in my target form.

I would really appreciate some help, I have been on this problem all day
surfing around this community picking up fragments of other peoples thoughts
and code to see if I could piece toghter a solution, which I thought I was
onto with my original post, whereby I get the form focus, goto the control,
tell it to find the record relating to the control that I have just left.

Anyway, as you suggested I have posted my question here:

http://www.microsoft.com/office/com...8ada&catlist=&dglist=&ptlist=&exp=&sloc=en-us



Marshall Barton said:
How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?
--
Marsh
MVP [MS Access]

I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]

efandango wrote:

I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"


Marshall Barton said:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.
 
M

Marshall Barton

I don't see a reason why that code would not move the focus
without at least generating some kind of error message.
Maybe there's something else getting in the way???

I am wondering if you might prefer to have the second
subform linked to the first subform so sf2 always displays
the record(s?) that are linked to the current record in sf1?
It's a different concept, but if that's sort of the effect
you are looking for, it would bypass the issues with the
current approach. If so, please enplain how you link the
records (in terms of the field in the tables).
--
Marsh
MVP [MS Access]

I think it because, as you say Windows should provide some visual cue, but
the cursor just highlights the data in my 'departue' text box (i'm using
d-click for the event), and the cursor doesn't go to the destination form
control. The reason I mentioned findng a record is because I was trying to
explain why i thought I needed the line: DoCmd.GoToControl "Joiner_Title_ID"
once I was in my target form.

I would really appreciate some help, I have been on this problem all day
surfing around this community picking up fragments of other peoples thoughts
and code to see if I could piece toghter a solution, which I thought I was
onto with my original post, whereby I get the form focus, goto the control,
tell it to find the record relating to the control that I have just left.


Marshall Barton said:
How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?

I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]


:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.


efandango wrote:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"
 
E

efandango

Marshall, (here is a fuller explanation and answer to your question about
table links, etc).

I have an overall (for all tab pages) Main Form called: 'frm_Runs'.
On one of these tabs, I have 3 forms:
1. frm_Street_Joiner_Main
2. frm_Street_Joiner_Sub
3. frm_Street_Joiner_Matches

Two of which belong together; they are:
1. 'frm_Street_Joiner_Main' (Subform of frm_Runs, linked by PK: Run_No on
overall main form)
2. 'frm_Street_Joiner_Sub' (Subform of above, frm_Street_Joiner_Main of
above is called:

Their tables are:
1. tbl_Street_Joiner_Main (PK: Joiner_Title_ID)
Linked to...
2. Table: tbl_Street_Joiner (Link Master Fields: Joiner_Title_ID)

The third table is display only, not for any data entry.
This is the display result of a complex set of queries that finds any dupes
in ‘tbl_Street_Joiner’ and cross matches them against any other occurances on
other records, and displays the results on this 3rd form
‘frm_Street_Joiner_Matches’ via a text box that I have named
[Other_Joiner_Title_ID].
This is not a subform of anything, and is not master/child related to any
other forms, but does contain in one of its columns, the crucial info that
tells me where other records matching the currently viewed master record on
‘frm_Street_Joiner_Sub/tbl_Street_Joiner’ occur. What I want to do is double
click any of the results in [Other_Joiner_Title_ID] rows in this form, such
that it will take me to the record via [Joiner_Title_ID].

So to summarise, I want to click and go from [Other_Joiner_Title_ID] on form
(frm_Street_Joiner_Matches)
To [Joiner_Title_ID] on form (frm_Street_Joiner_Sub)
using the data that is present in [Other_Joiner_Title_ID] as the record
number to get





Marshall Barton said:
I don't see a reason why that code would not move the focus
without at least generating some kind of error message.
Maybe there's something else getting in the way???

I am wondering if you might prefer to have the second
subform linked to the first subform so sf2 always displays
the record(s?) that are linked to the current record in sf1?
It's a different concept, but if that's sort of the effect
you are looking for, it would bypass the issues with the
current approach. If so, please enplain how you link the
records (in terms of the field in the tables).
--
Marsh
MVP [MS Access]

I think it because, as you say Windows should provide some visual cue, but
the cursor just highlights the data in my 'departue' text box (i'm using
d-click for the event), and the cursor doesn't go to the destination form
control. The reason I mentioned findng a record is because I was trying to
explain why i thought I needed the line: DoCmd.GoToControl "Joiner_Title_ID"
once I was in my target form.

I would really appreciate some help, I have been on this problem all day
surfing around this community picking up fragments of other peoples thoughts
and code to see if I could piece toghter a solution, which I thought I was
onto with my original post, whereby I get the form focus, goto the control,
tell it to find the record relating to the control that I have just left.


Marshall Barton said:
How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?


efandango wrote:
I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]


:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.


efandango wrote:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"
 
E

efandango

Marshall, (semi-good news...)

This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus

But it doesn't stay there, instead it comes back to my departure control and
highlights the control's data. How can I get it to now pick up the departure
controls's data and use it to go to the record on my target control?


Marshall Barton said:
I don't see a reason why that code would not move the focus
without at least generating some kind of error message.
Maybe there's something else getting in the way???

I am wondering if you might prefer to have the second
subform linked to the first subform so sf2 always displays
the record(s?) that are linked to the current record in sf1?
It's a different concept, but if that's sort of the effect
you are looking for, it would bypass the issues with the
current approach. If so, please enplain how you link the
records (in terms of the field in the tables).
--
Marsh
MVP [MS Access]

I think it because, as you say Windows should provide some visual cue, but
the cursor just highlights the data in my 'departue' text box (i'm using
d-click for the event), and the cursor doesn't go to the destination form
control. The reason I mentioned findng a record is because I was trying to
explain why i thought I needed the line: DoCmd.GoToControl "Joiner_Title_ID"
once I was in my target form.

I would really appreciate some help, I have been on this problem all day
surfing around this community picking up fragments of other peoples thoughts
and code to see if I could piece toghter a solution, which I thought I was
onto with my original post, whereby I get the form focus, goto the control,
tell it to find the record relating to the control that I have just left.


Marshall Barton said:
How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?


efandango wrote:
I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]


:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.


efandango wrote:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"
 
E

efandango

Marshal,

the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


efandango said:
Marshall, (semi-good news...)

This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus

But it doesn't stay there, instead it comes back to my departure control and
highlights the control's data. How can I get it to now pick up the departure
controls's data and use it to go to the record on my target control?


Marshall Barton said:
I don't see a reason why that code would not move the focus
without at least generating some kind of error message.
Maybe there's something else getting in the way???

I am wondering if you might prefer to have the second
subform linked to the first subform so sf2 always displays
the record(s?) that are linked to the current record in sf1?
It's a different concept, but if that's sort of the effect
you are looking for, it would bypass the issues with the
current approach. If so, please enplain how you link the
records (in terms of the field in the tables).
--
Marsh
MVP [MS Access]

I think it because, as you say Windows should provide some visual cue, but
the cursor just highlights the data in my 'departue' text box (i'm using
d-click for the event), and the cursor doesn't go to the destination form
control. The reason I mentioned findng a record is because I was trying to
explain why i thought I needed the line: DoCmd.GoToControl "Joiner_Title_ID"
once I was in my target form.

I would really appreciate some help, I have been on this problem all day
surfing around this community picking up fragments of other peoples thoughts
and code to see if I could piece toghter a solution, which I thought I was
onto with my original post, whereby I get the form focus, goto the control,
tell it to find the record relating to the control that I have just left.


:
How do you know that the focus did not move to the second
subform and ID text box? Windows should provide some
(subtle?) visual indication of where the focus is located.

Finding a record was not part of your original question. Do
you want to back up and describe what you are really trying
to accomplish and then ask a different question?


efandango wrote:
I did that, but their appears to be no visible sign that it has moved to the
form & control. Once there, I want to be able to say:

When I double click this control (on my departure form), got the 2nd
Subform/control and find the record that matches the departure control. Both
controls have the same name: [Joiner_Title_ID]


:
The GoToControl line is resetting the focus back to the
first subform. Get rid of it.


efandango wrote:
I have tried umpteen different ways to do this, but cannot get my head around
the complex syntax...

I double-click on a form control and want to go to a 2nd Subform elsewhere
on the Mainform.

My Mainform is called: 'frm_Runs'
My 1st 'target' Subform is called: 'frm_Street_Joiner_Main'
My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub'
My ultimate control on Subform2 is called: [Joiner_Title_ID]

How do I get there?

The code I have below just goes to the [Joiner_Title_ID] control that is on
my 'departure' form

Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
DoCmd.GoToControl "Joiner_Title_ID"
 
M

Marshall Barton

Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]

the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


efandango said:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
E

efandango

Marshall,

First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







Marshall Barton said:
Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]

the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


efandango said:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
M

Marshall Barton

I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.
--
Marsh
MVP [MS Access]

First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







Marshall Barton said:
Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]

the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
E

efandango

Marshall,

just to say quickly

I Understand, your time is precious and appreciate the time that have given
to me.

You didn't misunderstand my nesting; I mistakenly mislead you. (apologies,
but it is always late in the night here in the UK when I work on this, and
fatigue sets in).

Due no doubt to the to'ing and fro'ing of our postings, I think this has
become preceptively more complex than it actually is.

I will start from the top in my next posting; and pay more attention to what
I actually state.




Marshall Barton said:
I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.
--
Marsh
MVP [MS Access]

First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







Marshall Barton said:
Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]


efandango wrote:
the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
E

efandango

Marshall,

Forgetting for a moment all that has gone before. (ignore the previous
nesting because the subform that I was previously targetting is driven by its
master form, so simply no need to target the sub)

I have an overall (for all tab pages) Main Form called: 'frm_Runs' (using a
PK called [Run_No]).

On one of these tabs, I have 2 forms:

1. frm_Street_Joiner_Main (Linked to Main Form via [Run_No] (Single Form)
2. frm_Street_Joiner_Matches (not directly linked by any master/child
relationship) (Continuous Form)

Their tables/query are:

1. tbl_Street_Joiner_Main (PK: Joiner_Title_ID)
2. Qry_Street_Joiner_Matches:


I want to click and go from [Other_Joiner_ID] on form
(frm_Street_Joiner_Matches)
To [Joiner_Title_ID] on form (frm_Street_Joiner_Sub) finding the record that
matches the number.

So far, with the code below, I have been able to get the focus to the target
form, but not goto the record that matches the departure form.

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_ID

If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End Sub



efandango said:
Marshall,

just to say quickly

I Understand, your time is precious and appreciate the time that have given
to me.

You didn't misunderstand my nesting; I mistakenly mislead you. (apologies,
but it is always late in the night here in the UK when I work on this, and
fatigue sets in).

Due no doubt to the to'ing and fro'ing of our postings, I think this has
become preceptively more complex than it actually is.

I will start from the top in my next posting; and pay more attention to what
I actually state.




Marshall Barton said:
I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.
--
Marsh
MVP [MS Access]

First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







:

Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]


efandango wrote:
the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
E

efandango

Marshall, (I've been thinking, and trying to work out why your seemingly good
code will not budge the record number)

As previously mentioned, the form that I am trying to move the record on
'frm_Street_Joiner_Main', is sub linked to the overalll master form
'frm_Runs' via [Run_No].

For each 'frm_Runs' record, there is a 'frm_Street_Joiner_Main' record, do
you think that because we are trying to go to another record in
'frm_Street_Joiner_Main' that we should be moving the 'frm_Runs' record,
which would take the 'frm_Street_Joiner_Main' record with it, or can it work
either either way.

In other words, can the move 'child form' record, move the corresponding
'master form' record?

efandango said:
Marshall,

Forgetting for a moment all that has gone before. (ignore the previous
nesting because the subform that I was previously targetting is driven by its
master form, so simply no need to target the sub)

I have an overall (for all tab pages) Main Form called: 'frm_Runs' (using a
PK called [Run_No]).

On one of these tabs, I have 2 forms:

1. frm_Street_Joiner_Main (Linked to Main Form via [Run_No] (Single Form)
2. frm_Street_Joiner_Matches (not directly linked by any master/child
relationship) (Continuous Form)

Their tables/query are:

1. tbl_Street_Joiner_Main (PK: Joiner_Title_ID)
2. Qry_Street_Joiner_Matches:


I want to click and go from [Other_Joiner_ID] on form
(frm_Street_Joiner_Matches)
To [Joiner_Title_ID] on form (frm_Street_Joiner_Sub) finding the record that
matches the number.

So far, with the code below, I have been able to get the focus to the target
form, but not goto the record that matches the departure form.

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_ID

If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End Sub



efandango said:
Marshall,

just to say quickly

I Understand, your time is precious and appreciate the time that have given
to me.

You didn't misunderstand my nesting; I mistakenly mislead you. (apologies,
but it is always late in the night here in the UK when I work on this, and
fatigue sets in).

Due no doubt to the to'ing and fro'ing of our postings, I think this has
become preceptively more complex than it actually is.

I will start from the top in my next posting; and pay more attention to what
I actually state.




Marshall Barton said:
I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.
--
Marsh
MVP [MS Access]


efandango wrote:
First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







:

Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]


efandango wrote:
the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
E

efandango

Marshall,

Further to my very last post where I mention the relationship between my
target form and its parent form 'frm_Runs'


I have attempted to simplify things. I have removed the relationship between
the Overall Master form 'frm_Runs' and 'frm_Street_Joiner_Main', though the
latter is still contained within the former, there is no longer a logical
link.

Now the scenario is such that ''frm_Street_Joiner_Main' is autonomous from
anything else (except it has a continous subform, which is not relevant to
anything here.)


So now there are just two forms to contend with:

1. 'frm_Street_Joiner_Main'
and
2. frm_Street_Joiner_Matches

with two controls:

1. Joiner_Title_ID
and
2. Other_Joiner_ID

When I run your code:

*************************************
With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_ID

If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
*************************************

I get this error message: "Object doesn't support this property or method"

in the text highlighted ".Form.Bookmark = .Bookmark"

Hopefully, now that we have an actual error message, things will be clearer
for you.

Marshall Barton said:
I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.
--
Marsh
MVP [MS Access]

First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub







Marshall Barton said:
Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]


efandango wrote:
the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
M

Marshall Barton

We will never be able to find a record that is not in the
dataset as restricted by the LinkMaster/Child properties.
You definitely need to move the main form record if it does
not link to a subform record that you are trying to find.

You said that the frm_Runs' record has PK field Run_No and
implied that Run_No is a foreign key in
frm_Street_Joiner_Main's records.

You also said that the frm_Street_Joiner_Main record's PK
field is Joiner_Title_ID, which lines up with the values in
frm_Street_Joiner_Matches Other_Joiner_Title_ID field.

I previously thought that frm_Street_Joiner_Matches is a
subform on form frm_Runs side by side with
frm_Street_Joiner_Main. (I previously thought
frm_Street_Joiner_Matches was a subform in
frm_Street_Joiner_Main)

Regardless of what I thought before, I think you are now
saying that you need to get frm_Runs to the right record so
that frm_Street_Joiner_Main's recordset includes the record
you want to find. If this is indeed the situation, how can
the frm_Street_Joiner_Matches record identify the correct
record in frm_Runs?
--
Marsh
MVP [MS Access]

Marshall, (I've been thinking, and trying to work out why your seemingly good
code will not budge the record number)

As previously mentioned, the form that I am trying to move the record on
'frm_Street_Joiner_Main', is sub linked to the overalll master form
'frm_Runs' via [Run_No].

For each 'frm_Runs' record, there is a 'frm_Street_Joiner_Main' record, do
you think that because we are trying to go to another record in
'frm_Street_Joiner_Main' that we should be moving the 'frm_Runs' record,
which would take the 'frm_Street_Joiner_Main' record with it, or can it work
either either way.

In other words, can the move 'child form' record, move the corresponding
'master form' record?

efandango said:
Marshall,

Forgetting for a moment all that has gone before. (ignore the previous
nesting because the subform that I was previously targetting is driven by its
master form, so simply no need to target the sub)

I have an overall (for all tab pages) Main Form called: 'frm_Runs' (using a
PK called [Run_No]).

On one of these tabs, I have 2 forms:

1. frm_Street_Joiner_Main (Linked to Main Form via [Run_No] (Single Form)
2. frm_Street_Joiner_Matches (not directly linked by any master/child
relationship) (Continuous Form)

Their tables/query are:

1. tbl_Street_Joiner_Main (PK: Joiner_Title_ID)
2. Qry_Street_Joiner_Matches:


I want to click and go from [Other_Joiner_ID] on form
(frm_Street_Joiner_Matches)
To [Joiner_Title_ID] on form (frm_Street_Joiner_Sub) finding the record that
matches the number.

So far, with the code below, I have been able to get the focus to the target
form, but not goto the record that matches the departure form.

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_ID

If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End Sub



efandango said:
Marshall,

just to say quickly

I Understand, your time is precious and appreciate the time that have given
to me.

You didn't misunderstand my nesting; I mistakenly mislead you. (apologies,
but it is always late in the night here in the UK when I work on this, and
fatigue sets in).

Due no doubt to the to'ing and fro'ing of our postings, I think this has
become preceptively more complex than it actually is.

I will start from the top in my next posting; and pay more attention to what
I actually state.


:
I an going to need some time to come to grips with all this
and I have a very busy day today.

At this point all I can suggest is that you try what I
posted. If I misunderstood your nesting of subforms, and
what I posted goes off the rails, then see what you can do
to clarify the nesting for me.


efandango wrote:
First thing. I made a small mistake:

I don't need the 'subform' as it is the parent of the sub that controls the
overall record number; so I removed your second line.

'With .Form!frm_Street_Joiner_Sub
.SetFocus'

In saying that, yes it goes to the correct control, but for some reason
doesn't advance to the record number from the departure box...



This is now my current code:

Private Sub Other_Joiner_ID_Click()

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With

End Sub


:
Let's make those long lines shorter too.

Assuming the ID fields are a numeric type, I think this
should do all that:

With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form!frm_Street_Joiner_Sub
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_Title_ID
If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
End With
--
Marsh
MVP [MS Access]


efandango wrote:
the code below works and goes to my target control, and stays there!... (it
was the double-click action that was throwing it back, when I changed to
single click it worked)

Can you help me to now get it to pick up the departure controls's data and
use it to go to the record on my target control?


:
This code goes to the form AND control that I want: (I know this because the
target control flashes momentarily)

Forms!frm_Runs!frm_Street_Joiner_Main.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.SetFocus
Forms!frm_Runs!frm_Street_Joiner_Main.Form!frm_Street_Joiner_Sub.Form![Joiner_Title_ID].SetFocus
 
M

Marshall Barton

efandango said:
Further to my very last post where I mention the relationship between my
target form and its parent form 'frm_Runs'


I have attempted to simplify things. I have removed the relationship between
the Overall Master form 'frm_Runs' and 'frm_Street_Joiner_Main', though the
latter is still contained within the former, there is no longer a logical
link.

Now the scenario is such that ''frm_Street_Joiner_Main' is autonomous from
anything else (except it has a continous subform, which is not relevant to
anything here.)


So now there are just two forms to contend with:

1. 'frm_Street_Joiner_Main'
and
2. frm_Street_Joiner_Matches

with two controls:

1. Joiner_Title_ID
and
2. Other_Joiner_ID

When I run your code:

*************************************
With Forms!frm_Runs!frm_Street_Joiner_Main
.SetFocus
With .Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Joiner_Title_ID=" _
& Other_Joiner_ID

If Not .NoMatch Then .Form.Bookmark = .Bookmark
End If
End With
.Form!Joiner_Title_ID.SetFocus
End With
*************************************

I get this error message: "Object doesn't support this property or method"
in the text highlighted ".Form.Bookmark = .Bookmark"


Arrggghhh, I lost track of the nested Withs.

Try this instead:

If Not .NoMatch Then
Forms!frm_Runs!frm_Street_Joiner_Main.Form.Bookmark =
..Bookmark
End If
 
E

efandango

Marshall,

that is quite simply... beautiful.

works a charm, I am so grateful for your help.

2 things (only if you have the time)

1. If I wanted to re-link my target form 'frm_Street_Joiner_Main' with my
overall Master Form 'frm_Runs', what would the revised code be?

2. What was going on with this most recent broken code?, you mentioned the
nested withs; I would like to learn going forward, rather than rely soley on
your generosity and gifted code.

regards

Eric
 
M

Marshall Barton

1) You could try setting the LinkMaster/Child properties.
Maybe something like:

With Forms!frm_Runs.frm_Street_Joiner_Main
.LinkChildFields = "Run_No" 'check these field names
.LinkMasterFields = "Run_No"
End With

To remove them, just set them to the zero length string ""

An alterative might(?) be to manipulate
frm_Street_Joiner_Main's Filter property. If you use a
filter on the main form or any other subform, that won't
work because a bug that erases the other filters.

2) I was using the outer With's object inside the inner
With. A stupid mistake on my part. Look at the code that
worked and compare it the one that didn't work.
 

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