UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Trapping Removal Of Filter On Datasheet, Access 2016    
 
   
jghogue
post Jul 12 2019, 07:20 AM
Post#1



Posts: 30
Joined: 14-January 16



Greetings All!

In VBA, How do I trap when a user removes all filters from a datasheet form?

Thanks.

jghogue
Go to the top of the page
 
ADezii
post Jul 12 2019, 07:54 AM
Post#2



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


To the best of my knowledge, there is no specific Event that Traps when a Filter is removed. I would imagine that at any point in time you can check the FilterOn Property of that Form to see if a Filter is active or not. An example (UNTESTED) would be:
CODE
Dim frm As Access.Form

Set frm = Forms("frmDatasheet")

MsgBox IIf(frm.FilterOn, "Filter is ON", "Filter is OFF")
Go to the top of the page
 
dale.fye
post Jul 12 2019, 08:20 AM
Post#3



Posts: 70
Joined: 28-March 18
From: Virginia


there is an ApplyFilter event (or something like that) at the form level. You might test to see whether this fires when a filter is removed as well.

--------------------
Dale Fye
Microsoft Access MVP 2013-2016
Developing Solutions, LLC
Go to the top of the page
 
GroverParkGeorge
post Jul 12 2019, 08:55 AM
Post#4


UA Admin
Posts: 35,312
Joined: 20-June 02
From: Newcastle, WA


I wonder if there is another way to achieve the goal here. WHY do you want to know if a filter has been removed? What will your form do when that happens?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
ADezii
post Jul 12 2019, 09:48 AM
Post#5



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


I did a little more research and found that the ApplyType Argument of the ApplyFilter() Event will return 0 (acFilterByForm) once a Filter is removed either programatically or via the Toggle Filer Option. I also would like to know why you would want to be notified when a Filter is removed?
CODE
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
If ApplyType = acFilterByForm Then
  MsgBox "Filter has been removed"
End If
End Sub

This post has been edited by ADezii: Jul 12 2019, 09:49 AM
Go to the top of the page
 
jghogue
post Jul 12 2019, 10:20 AM
Post#6



Posts: 30
Joined: 14-January 16



Hi there,

I needed to know to display totals of filtered data on a parent form. ApplyFilter does not reset .filter when all filters are removed. Works great when filters are applied. FilterOn also does not get reset.

I tried testing ApplyType (thank you ADezii) and that solved my problem.

jghogue
Go to the top of the page
 
ADezii
post Jul 12 2019, 10:30 AM
Post#7



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


thumbup.gif , glad it worked out for you.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th July 2019 - 02:11 PM