Hi,
I am assuming that by "subform" you mean a second form? Otherwise your main form's design view you should be able to use the subform wizard to insert the subform into the main form an link it with a parent/child link...
So here is the code for opening a second form from a main form:
If you are using a form then the code for your "On Click" event should look something like this:
- Change Form2Name to your second form's name
- Change UniqueID to the name of the field in your form that holds the unique id for the record
- Change UniqueID2 to fit the name of the second form's foreign unique id field
(I.E. - I have 2 tables, Table1 has a field called lastname, Table2 also has a lastname field which references the Table1 lastname)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Form2Name"
stLinkCriteria = "[UniqueID]=" & Me![UniqueID2]
DoCmd.OpenForm stDocName, , , stLinkCriteria
HTH,
jbehrne If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations