# How to apply a filter to a browse

**URL:** <https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426>\
**Category:** faq\
**Created:** [October 13, 2026, 2:02pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426 "2026-10-13T14:02:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisBos](https://clarionhub.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ChrisBos](https://clarionhub.com/u/ChrisBos)\
**Post date:** [October 13, 2026, 2:02pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/1 "2026-10-13T14:02:25Z")

</div>

I have a Browse procedure that I want to filter based on an empty Date field.  
There is Boolean variable set to 0 at window opening and a Button to apply or remove the filter.  
The following code is placed in ThisWindow.TakeAccepted procedure.  
Apparently "empty" Date fields default to 1/1/0001. I have tried several filters with and without the Year() function, including 0, \< various numbers, and Not.  
No compile errors occur. Usually clicking the filter button has no effect, occasionally I get a run-time error about inability to apply an invalid filter.  
Any advice as to what to do differently will be much appreciated. TIA

```clarion
     ! Start of "Control Event Handling, after generated code"
      ! [Priority 5000]
      If Filtered = 0
      	BRW1.SetFilter('Year(Lns:DateReturned) = 1')
      	BRW1.ApplyFilter
      	Filtered = 1
      ElsIf Filtered = 1
      	BRW1.SetFilter('')
      	BRW1.ApplyFilter
      	Filtered = 0
      End 
      ThisWindow.Update()
      
      ! End of "Control Event Handling, after generated code"
      ! End of "Control Event Handling"

```

---

<div class="post-metadata">

**Author:** ![ChrisBos](https://clarionhub.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ChrisBos](https://clarionhub.com/u/ChrisBos)\
**Post date:** [October 13, 2026, 2:03pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/2 "2026-10-13T14:03:12Z")

</div>

Perhaps I should mention that the Browse has only one key.

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [October 13, 2026, 6:17pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/3 "2026-10-13T18:17:01Z")

</div>

What driver? What database?

---

<div class="post-metadata">

**Author:** ![Bjarne\_Havnen](https://clarionhub.com/user_avatar/clarionhub.com/bjarne_havnen/32/1350_2.png) [@Bjarne\_Havnen](https://clarionhub.com/u/Bjarne_Havnen)\
**Post date:** [October 13, 2026, 7:28pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/4 "2026-10-13T19:28:24Z")

</div>

First I notice is Year=1, can't happen, not after Christ's crusification

Next: setfilter has a second name parameter. Without using that, resetsort will apply standard filters.

Setfilter applies to current sort order, you will need to add a new sort order to replace existing criterias. I might be remembering wrong, but there might be some wildcard filtername you can use to replace, consult the docs on setfilter.

---

<div class="post-metadata">

**Author:** ![ChrisBos](https://clarionhub.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ChrisBos](https://clarionhub.com/u/ChrisBos)\
**Post date:** [October 13, 2026, 8:25pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/5 "2026-10-13T20:25:42Z")

</div>

This is a TPS File; not SQL. All files in Application are TPS.  
And just in case: Clarion 12; ABC.template chain

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [October 13, 2026, 9:48pm UTC](https://clarionhub.com/t/how-to-apply-a-filter-to-a-browse/9426/6 "2026-10-13T21:48:17Z")

</div>

And what is the Key and its field elements?

Using a Key where its field elements are used in a filter, will speed up the filter process.

If the key does not have the field elements that are used in a filter, the filter will take longer to go through the TPS file.
