Okay this is the situation I have two forms and they have a 1:M relationship. I don't have enough space screen-wise to do a traditional "drag form to form" to create a subform so what I did was create command buttons that open the subform when I click on it.
I added a filter to the VBA that filters the results of the subform to display only records that match the linking field of the two forms. And it those and would filter but..I am having problems when I putting information into the subform. The issue is the foriegn key value(CaseNo) (in the underlying table: tblHearings, fyi. the form name is frmHearings, and table name is tblHearings) that is in subform does not get populated with the primary key value(CaseNo) of the parent form that entered before opening the subform. The field that links the two table together is: CaseNo. This is the code I used:
to filter the informtion that appears in the subform and it does filter the information if I manually type in the matching, in my case "CaseNo" in the "tblHearing " table but it shouldn't work like that. I want the foreign key field in that "TblHearing " table to be automatically populated, on the table level, with the primary key value of the parent form. Can you or anyone else lend some assistance? I have been racking my brain for a few days trying to get this and I am drawing complete blanks.
I added a filter to the VBA that filters the results of the subform to display only records that match the linking field of the two forms. And it those and would filter but..I am having problems when I putting information into the subform. The issue is the foriegn key value(CaseNo) (in the underlying table: tblHearings, fyi. the form name is frmHearings, and table name is tblHearings) that is in subform does not get populated with the primary key value(CaseNo) of the parent form that entered before opening the subform. The field that links the two table together is: CaseNo. This is the code I used:
Code:
Private Sub Command52_Click() On Error GoTo Err_Command52_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmHearings" stLinkCriteria = "[CaseNo]=" & "'" & Me![CaseNo] & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command52_Click: Exit Sub Err_Command52_Click: MsgBox Err.Description Resume Exit_Command52_Click End Sub
Comment