Applying filter to one subform based on selection of other subform

J

jhanby1

Ok, so I have a form (frmMainPage) with 2 subforms (frmCaseSearch &
frmCaseDetails) on 1 tab. When frmMainPage opens, the frmCaseSearch is
visible, and frmCaseDetails is not visible. When I double click on the
lstCases in frmCaseSearch, frmCaseSearch.Visible is set to false, and
frmCaseDetails.Visible is set to true. My problem lies in filtering
frmCaseDetails to show the details for the case that was selection in
lstCases on the frmCaseSearch page. I am not sure of syntax or where to
locate the filter. I need to filter frmCaseDetails based on a field
"tblCasesID" which is located in both lstCases from frmCaseSearch, and
frmCaseDetails.

And now that I have thoroughly confused you all, please help me! Any
suggestions?
 
J

jhanby1

Here is the code I have in the On DoubleClick event for lstCases on the
frmCaseSearch form.

Private Sub lstCases_DblClick(Cancel As Integer)

Dim strCaseSelection As String, frm As Form

strCaseSelection = Forms!frmMainPage!fsubCaseSearch!lstCases

Set frm = Forms!frmMainPage!fsubCaseDetails.Form
frm.Filter = "tblCasesID = " & strCaseSelection
frm.FilterOn = True

Forms!frmMainPage!fsubCaseDetails.Visible = True
Forms!frmMainPage!fsubCaseDetails.SetFocus
Forms!frmMainPage!fsubCaseSearch.Visible = False
End Sub

Access encounters errors and shutsdown.
 
Top