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