Filter on Load (1 Viewer)

XPS35

Active member
Local time
Today, 12:50
Joined
Jul 19, 2022
Messages
159
if there are only 2 choices you simply need

me.filteron = not me.yourcheckboxname
How simple can it be? At least so simple that I couldn't think of it šŸ¤¢
 

moke123

AWF VIP
Local time
Today, 06:50
Joined
Jan 11, 2013
Messages
3,920
Personally I would just have a procedure

Code:
Private sub MyFilter()
Dim strFilter as string

strfilter = "SomeField = " & SomeValue
me.filterOn = not Me.MyCheckBox             ' or  me.filterOn =  Me.MyCheckBox   depending on how you want to filter

end sub

Then just call it in form load and the after update of the checkbox.

The bigger problem will be the fiscal year dates year after year which OP will have to eventually address.
 

cktcPeterson

Member
Local time
Today, 02:50
Joined
Mar 23, 2022
Messages
73
if there are only 2 choices you simply need

Code:
me.filter = "[Completion Time] Between #10/1/2022# And #9/30/2023#"

me.filteron = not me.ckbxSeeAll
That worked!

Thanks so much!
 

moke123

AWF VIP
Local time
Today, 06:50
Joined
Jan 11, 2013
Messages
3,920
Your welcome. What are you going to do next fiscal year?
 

cktcPeterson

Member
Local time
Today, 02:50
Joined
Mar 23, 2022
Messages
73
What are you going to do when you hit the next fiscal year? If you are hard coding the filter you'll have to change it each year.

It would seem to me that all you want to do is toggle the filter on or off.

In the attached I have a field in the forms record source which is the fiscal year for the date field.
A combo box has a row source of all the distinct FY's.
The check box toggles the filter on or off.
I used this example and it worked great. Now that I am in FY24 how do I make the default (filter) year 2024?
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:50
Joined
Sep 21, 2011
Messages
14,302
I used this example and it worked great. Now that I am in FY24 how do I make the default (filter) year 2024?
Test the current date and construct the filter accordingly?
 

moke123

AWF VIP
Local time
Today, 06:50
Joined
Jan 11, 2013
Messages
3,920
I used this example and it worked great. Now that I am in FY24 how do I make the default (filter) year 2024?
Maybe change the load event as shown.
instead of using year(date) as the value for the combo, use the current fiscal year.

Code:
Private Sub Form_Load()
    Me.cboFY = GetFiscalYear(Date, 10)
    Me.Check21 = -1
    FilterMe
    
End Sub
 

Users who are viewing this thread

Top Bottom