L
Leslie Isaacs
Hello All
I have a main form called [frm x main], which has a subform called [qry x
main table subform] (representing a set of people). The subform opens in
datasheet view, and includes a field called [name] (yes - I know the naming
convention is terrible - but I inherited this and so far it all works!).
There is another (main) form called [staffs subform new] (based on all the
people in the database), which also contains the same [name] field as [qry x
main table subform]. I would like to be able to open [staffs subform new] by
double-clicking the [name] fields in one of the records of [qry x main table
subform] so that [staffs subform new] opens at the record corresponding to
the selected record in [qry x main table subform]. The code I have as the
doubleclick event for [name] in [qry x main table subform] is below, which
does open the form but not at the selected record. I have used this code
before from a main form and it works perfectly, so I am assuming that the
problem is to do with trying to reference the required field from a subform.
Hope someone an help.
Many thanks
Les
My code:
Private Sub Name_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "staffs subform new"
stLinkCriteria = "[name]=" & "'" & Me![name] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
I have a main form called [frm x main], which has a subform called [qry x
main table subform] (representing a set of people). The subform opens in
datasheet view, and includes a field called [name] (yes - I know the naming
convention is terrible - but I inherited this and so far it all works!).
There is another (main) form called [staffs subform new] (based on all the
people in the database), which also contains the same [name] field as [qry x
main table subform]. I would like to be able to open [staffs subform new] by
double-clicking the [name] fields in one of the records of [qry x main table
subform] so that [staffs subform new] opens at the record corresponding to
the selected record in [qry x main table subform]. The code I have as the
doubleclick event for [name] in [qry x main table subform] is below, which
does open the form but not at the selected record. I have used this code
before from a main form and it works perfectly, so I am assuming that the
problem is to do with trying to reference the required field from a subform.
Hope someone an help.
Many thanks
Les
My code:
Private Sub Name_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "staffs subform new"
stLinkCriteria = "[name]=" & "'" & Me![name] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub