A
Amduke
Hello all,
the problem I encounter is probebly easy to solve, but I don't get it.
I have a form with a listbox. On the on-click event I startup a form with
datainformation related to the item in the listbox. So far so good.
Now I'm trying to display a subform with a 1 to many relation and filtered,
based on the item of the listbox.
When doing this, I see the subform but all the records of the table are
visible. It seems that de filter doesn't work at all.
How can I solve this.
Here is the code out of the subform:
Private Sub Form_Load()
If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If
Dim strSQL As String
If IsNull(Me.Mabc8) Then
' If the listbox is Null, use the whole table as the RecordSource.
Me.RecordSource = "tbl_1_OrdersToLate"
Else
strSQL = "SELECT DISTINCTROW tbl_1_OrdersToLate.* FROM
tbl_1_OrdersToLate " & _
"INNER JOIN Tbl_1_BasicMaterial ON " & _
"tbl_1_OrdersToLate.mabc8 = Tbl_1_BasicMaterial.mabc8 " & _
"WHERE (((Tbl_1_BasicMaterial.Mabc8)=""" & Me.Mabc8 & """));"
Me.RecordSource = strSQL
End If
' Apply the filter again, if it was on.
If bWasFilterOn And Not Me.FilterOn Then
Me.FilterOn = True
End If
If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If
End Sub
the problem I encounter is probebly easy to solve, but I don't get it.
I have a form with a listbox. On the on-click event I startup a form with
datainformation related to the item in the listbox. So far so good.
Now I'm trying to display a subform with a 1 to many relation and filtered,
based on the item of the listbox.
When doing this, I see the subform but all the records of the table are
visible. It seems that de filter doesn't work at all.
How can I solve this.
Here is the code out of the subform:
Private Sub Form_Load()
If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If
Dim strSQL As String
If IsNull(Me.Mabc8) Then
' If the listbox is Null, use the whole table as the RecordSource.
Me.RecordSource = "tbl_1_OrdersToLate"
Else
strSQL = "SELECT DISTINCTROW tbl_1_OrdersToLate.* FROM
tbl_1_OrdersToLate " & _
"INNER JOIN Tbl_1_BasicMaterial ON " & _
"tbl_1_OrdersToLate.mabc8 = Tbl_1_BasicMaterial.mabc8 " & _
"WHERE (((Tbl_1_BasicMaterial.Mabc8)=""" & Me.Mabc8 & """));"
Me.RecordSource = strSQL
End If
' Apply the filter again, if it was on.
If bWasFilterOn And Not Me.FilterOn Then
Me.FilterOn = True
End If
If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If
End Sub