0
votes

I have an unbounded Form Called [frmTestsMain] which includes 3 subforms:

  1. [frmTestsList]
  2. [frmTMGroupList]
  3. [frmTSGroupList]

  • [frmTMGroup] has a filed "TMGroup",
  • [frmTSGroup] has a filed called "TSGroup" and another lookup filed "TMGroup" linked to [frmTMGroup].TMGroup.
  • [frmTestsList] has lookup filed "TSGroup" linked to [frmTSGroup].TSGroup.

What I want is:

  1. When I click [frmTMGroup].TMGroup, the other subform [frmTSGroup] to be filtered to get only TMGroup clicked.
  2. When I click [frmTSGroup].TSGroup, the other subform [frmTestsList] to be filtered to get only TSGroup clicked.

I wrote the code like below and worked with no problems If I open the [frmTestsMain] directly.

Private Sub TestMGroup_Click()
Forms![frmTestsMain]![frmTSGroupList].Form.Filter = "TestMGroup =" & Me.ID

Forms![frmTestsMain]![frmTSGroupList].Form.FilterOn = True 
 End Sub

and

 Private Sub TestSGroup_Click()
 Forms![frmTestsMain]![frmTestsList].Form.Filter = "TestSGroup =" & Me.ID
 Forms![frmTestsMain]![frmTestsList].Form.FilterOn = True
 End Sub

But when I included the [frmTestsMain] from in A navigation form with a min from , i get an error.

I tried to modify the code like the following but I get the same problem

Private Sub TestMGroup_Click()
Forms![frmMain]![NaviTests]![frmTestsMain]![frmTSGroupList].Form.Filter = "TestMGroup =" & Me.ID

Forms![frmMain]![NaviTests]![frmTestsMain]![frmTSGroupList].Form.FilterOn = True 
 End Sub

Could you help me please. Thanks

1
i read this post but could not understand the solution : stackoverflow.com/questions/16041901/… - Emad Mohamed
Is TestMGroup a number or a string? If it's a string you have to surround Me.ID with quotes .Filter = "TestMGroup = '" & Me.ID & "'" - BitAccesser
I modified the code to be : Forms![frmMain]![NaviTests]![frmTestsMain]![frmTSGroupList].Form.Filter = "TestMGroup =" & Me.ID & "'" OR as Forms![frmTestsMain]![frmTSGroupList].Form.Filter = "TestMGroup =" & Me.ID & "'" but i still get an errorbut i still get an error - Emad Mohamed
The error details: run-time error '438' : Object doesn't support this property or method. - Emad Mohamed

1 Answers

0
votes

I found the solutions, and thanks for all the people here and there who helped me to figure it out

Private Sub TestMGroup_Click()
Forms![frmMain]![NavigationSubform].Form![frmTSGroupList].Form.Filter = "TestMGroup =" & Me.ID
Forms![frmMain]![NavigationSubform].Form![frmTSGroupList].Form.FilterOn = True
End Sub

Thanks