navigate to record on form and subform

M

msmuzila

I know how to navigate to a form and a subform from a different form,
but i dont know how to do it when the form and subform is on the form
with the control (making the form and subform a subform and
sub-subform). Here is the code for the first way, can someone show me
how to modify it to do it the second way. I know the Docmd needs to go,
but i dont know how to make frmAdd_Disk into a subform and the frmDisk
into a sub-subform.


Private Sub List4_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String
Dim rs As Object

stDocName = "frmAdd_Disk"

stLinkCriteria = "[Software ID]=" & Me![List0]
DoCmd.OpenForm stDocName
Set rs = Forms(stDocName).Recordset.Clone
rs.FindFirst stLinkCriteria
If Not rs.EOF Then Forms(stDocName).Bookmark = rs.Bookmark

Set frm = Forms("frmAdd_Disk").[frmDisk].Form

With frm.RecordsetClone
.FindFirst "Disk ID = " & Me![List1]
If .NoMatch Then
MsgBox "Not found in subform"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing

End Sub





Many thanks
 
L

Larry Linson

I know how to navigate to a form and a subform from a different form,
but i dont know how to do it when the form and subform is on the form
with the control (making the form and subform a subform and
sub-subform). Here is the code for the first way, can someone show me
how to modify it to do it the second way. I know the Docmd needs to go,
but i dont know how to make frmAdd_Disk into a subform and the frmDisk
into a sub-subform.

Just for the record, you don't "make a form into a subform (or
sub-subform)". There are Subform Controls into which you can embed a Form as
the SourceObject. The Form so embedded may have its own Subform Control, and
another Form may be embedded as the Source Object of that one -- which, in
verbal shorthand, we might call a subsubform.

You relate the Records displayed in a Subform Control to the Record
displayed in its Parent, by specifying the LinkMasterFields and
LinkChildFields properties of the Subform Control. LinkMasterFields and
LinkChildFields can be one, or multiple, fields in the RecordSource of the
two Forms (or alternatively can specify a Control on the parent Form -- and,
though I can't recall doing so, on the Form in the Subform Control, as
well).

If you are using that approach to synchronizing the Forms with the Subform
Control, you will likely need no code at all to accomplish what you want to
do.

Larry Linson
Microsoft Access MVP



Private Sub List4_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String
Dim rs As Object

stDocName = "frmAdd_Disk"

stLinkCriteria = "[Software ID]=" & Me![List0]
DoCmd.OpenForm stDocName
Set rs = Forms(stDocName).Recordset.Clone
rs.FindFirst stLinkCriteria
If Not rs.EOF Then Forms(stDocName).Bookmark = rs.Bookmark

Set frm = Forms("frmAdd_Disk").[frmDisk].Form

With frm.RecordsetClone
.FindFirst "Disk ID = " & Me![List1]
If .NoMatch Then
MsgBox "Not found in subform"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing

End Sub





Many thanks
 
M

msmuzila

that is usually how i do it, but it did not give me that option. When i
try to link, i says "cannot create a link between unbound forms" Not
sure what this means. How would i fix it to be able to link the forms
 

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