Remove Specific Filters

jacksonwearn

New member
Local time
Today, 12:23
Joined
Jun 14, 2013
Messages
9
So I have been developing a database tool that needs to have multiple ways of filtering data. I wanted to be able to display the data nicely so I'm using a split form.

As usual, there is an easy to read form on the top half and a datasheet on the bottom half. On one side of the form half I have some comboboxes that are associated with fields in the datasheet. The comboboxes apply multiple filters, narrowing the search results down. It all works fine.

However, I've been trying to figure out a way to remove just one filter at a time. There is a button to the right of each combobox that is intended to clear just one filter.

So far this is what I have. This code clears all filters.

Code:
Function removeFilter(source As String, combo As ComboBox)

'source is the field being filtered and combo is the current
'value of the combobox

With Forms("PART_QUERY")
    .Filter = "[" & source & "] = " & Chr(34) & combo & Chr(34)
    .FilterOn = False
End With

End Function
I had some success using another method with select statements. Every time I cleared a filter, I would also check every other combobox to see if they were not null, then reapply each one of there filters. That seems way over complicated. I'm sure I'm missing something.

TL;DR How do I remove one, specific filter from a split form, after I have applied many different filters? :banghead:

Any help is appreciated :)

Thanks,
Jackson
 
Try YourCombo Box.Requery

Dale

I'm not sure how you intend for me to use requery. I've tried placing it in a couple different ways in my existing VBA but it doesn't seem to do anything. Can you please elaborate?
 
Code:
    [FONT=&quot]Function removeFilter(source As String, combo As ComboBox)[/FONT]
  [FONT=&quot] [/FONT]
  [FONT=&quot]'source is the field being filtered and combo is the current[/FONT]
  [FONT=&quot]'value of the combobox[/FONT]
  [FONT=&quot] [/FONT]
  [FONT=&quot]With Forms("PART_QUERY")[/FONT]
  [FONT=&quot]    .Filter = "[" & source & "] = " & Chr(34) & combo & Chr(34)[/FONT]
  [FONT=&quot]    .FilterOn = False[/FONT]
  [FONT=&quot]End With[/FONT]
  [FONT=&quot]Your Combo box name[B][U].Requery[/U][/B][/FONT]
  [FONT=&quot]End Function[/FONT]


Dale
 
Thanks for the reply. I ended up totally restructuring my code and figured out how to accomplish what I needed with another method.
 

Users who are viewing this thread

Back
Top Bottom