Applying filter to one subform based on selection of other subform

  • Thread starter Thread starter jhanby1
  • Start date Start date
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?
 
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.
 

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

Back
Top