Nick Mirro said:
When using an open form command, I would like the new form to open to
(display a specific record) in its subform. The originating form and
the destination form's subform have the same recordset, so I can link
the primary keys.
How can I get the new form to open so that its "subform" displays a
specific record?
Is the subform linked via Link Master/Child Fields to its parent form?
That will naturally constrain the contents of the subform. And do you
want to *locate* a record in the subform, or filter the subform to show
only the matching record?
You can use code like this to manipulate the subform after opening its
parent form:
'----- Warning: AIR CODE -----
Dim frm As Form
DoCmd.OpenForm "ParentForm"
Set frm = Forms!ParentForm!SubformControl.Form
'*** OPTION 1: Locate subform record
With frm.RecordsetClone
.FindFirst "ID=" & Me.ID
If Not .NoMatch Then
frm.Bookmark = .BookMark
End If
End With
'*** OPTION 2: Filter the subform
With frm
.Filter = "ID=" & Me.ID
.FilterOn = True
End With
' Needed for either opton:
Set frm = Nothing
'----- end of AIR CODE -----
Note: in the above, "ParentForm" is the name of the form you open that
contains the subform, and "SubformControl" is the name of the subform
control on that form that displays the subform.