Link to home
Start Free TrialLog in
Avatar of First Last
First Last

asked on

filter continuous form with button and one date field

Hello.  Using A2013 for front and back end with linked tables.  I have a continuous form that is being used as a diary for the users.  After awhile, the diaries are rather plentiful.  There is a date field (short date) when the diary is completed.  Otherwise, the field is empty.   What is looking to be done is have a button and when clicked, the diaries with completion dates will hide or be filtered out.  The same button is clicked and all the diaries come back (a toggling back and forth - but not to use toggle button).  It has to be so that all the diaries can be seen when needed.  The continuous form's recordsource is the table (actually the query builder was used so the due dates are descending) and the diary is added on the form and into the table.  This full A2013 app is to be as simple for the user as possible.  Diary form is only one form in the full app.

I have tried the following:
DoCmd.ApplyFilter = ...  (this gave error about filter or where not set - that thru me off and not sure what it meant)
me.filter = ...  followed by me.filter = true  (even tried all these in an IF statement - but no go)
Even tried to use the Sort & Filter menu on the ribbon but realized that the ribbon is collapsed on most all machines.  

Can someone point me in the right direction in using the button to filter completed/not completed?

Thanks..... John
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Well check this
Option Compare Database
Dim toggleStatus As Boolean
Private Sub cmdFilterDates_Click()
Me.FilterOn = False

Me.Filter = "IsDate(TheNameOfTheDateField) =" & toggleStatus
toggleStatus = Not toggleStatus
Me.FilterOn = True
End Sub

Open in new window

You will need one more button to reset entirely the filtering
Private Sub cmdResetDates_Click()
Me.Filter = ""
Me.FilterOn = true
End Sub

Open in new window

Attach is a sample DB with "fromListBox" and "frmEdit" which have the require functionality. Hope this help.
Wsm93--1-.accdb
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.