Filter on form not working as intended to filter subform (1 Viewer)

Zippersabrat

Blah Blah Blah :o)
Local time
Today, 13:17
Joined
May 5, 2010
Messages
31
I am using the below code to filter a subform based on the main form field of [Product Product Type]. The subform will filter based on the field [Product Type]. If I manually change the dropdown on the main form it will filter the subform. I do not want the user to have to do this as they will end up making a mess. I want that field to auto-update as they go through the data and then filter the subform based on the given value. In the past, I had this filter working but now I cannot seem to get it to function correctly. Can anyone tell me what I am doing wrong?

Code:
Private Sub Product_Type_AfterUpdate()

Me.Central_Structure_Product_List.Requery

Dim strType As String
Dim strFilter As String

If Not IsNull(Me.[Product Product Type].Value) Then
strType = "='" & Me.[Product Product Type].Value & "'"
Else
strType = "=" & Me.[Product Product Type] Like "" * """"
End If

strFilter = "[Product Type] " & strType & ""

With Me![Central Structure Product List].Form
.Filter = strFilter
.FilterOn = True
End With
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:17
Joined
Oct 29, 2018
Messages
21,358
Hi. What do you have now in the Linked Master and Linked Child Fields properties?
 

Ranman256

Well-known member
Local time
Today, 16:17
Joined
Apr 9, 2015
Messages
4,339
you dont need the .value

Code:
If Not IsNull(Me.[Product Product Type]) Then
strFilter = "[Product Type] = '" & Me.[Product Product Type] & "'"
Else
strFilter = "[Product Type] like '*" & Me.[Product Product Type] & "*'"
End If
 

Users who are viewing this thread

Top Bottom