Filtering using subform

D

dbpatadia

i have a form with three Option groups and one combo box and i am
trying to filter it out to the subform that i have on the same form.
here is the code, everytime i try to click on Apply Filter. its not
working. my filter is not showing on the subform. this code is behide
Apply filter command on the main form. so i need code behide the
subform. the Subform contains the main table that show all the fields.



Dim strmarket As String
Dim stradvertisers As String
Dim strheading As String
Dim strudac As String
Dim strfilter As String


If IsNull(Me.txtmarket.Value) Then
strmarket = "Like '*'"
Else
Select Case Me.fraMarket.Value
Case 1
strmarket = "Like '" & Me.txtmarket.Value & "*'"
Case 2
strmarket = "Like '*" & Me.txtmarket.Value & "*'"
Case 3
strmarket = "Like '*" & Me.txtmarket.Value & "'"
Case 4
strmarket = "= '" & Me.txtmarket.Value & "'"
End Select
End If



If IsNull(Me.txtAdvertisers.Value) Then
stradvertisers = "Like '*'"
Else
Select Case Me.fraAdvertisers.Value
Case 1
stradvertisers = "Like '" & Me.txtAdvertisers.Value & "*'"
Case 2
stradvertisers = "Like '*" & Me.txtAdvertisers.Value & "*'"
Case 3
stradvertisers = "Like '*" & Me.txtAdvertisers.Value & "'"
Case 4
stradvertisers = "= '" & Me.txtAdvertisers.Value & "'"
End Select
End If



If IsNull(Me.TxtHeading.Value) Then
strheading = "Like '*'"
Else
Select Case Me.FraHeading.Value
Case 1
strheading = "like '" & Me.TxtHeading.Value & "*'"
Case 2
strheading = "Like '*" & Me.TxtHeading.Value & "*'"
Case 3
strheading = "Like '*" & Me.TxtHeading.Value & "'"
Case 4
strheading = Me.TxtHeading.Value & ""
End Select
End If


If IsNull(Me.CboUDAC.Value) Then
strudac = "like '*'"
Else
strudac = "='" & Me.CboUDAC.Value & "'"
End If

strfilter = "[market] " & strmarket & " and [advertisers] " &
stradvertisers & " and
" & strheading


With SubForm![frmMeterAdSubform]
..filter = strfilter
..FilterOn = True

End With


End sub​
 

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

Top