Solved Code required for hiding "[Status]=Closed" records on continuous forms (1 Viewer)

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
Hi all,

I am looking to develop a continuous form that contains all "task" records from a task management DB. Note, I have not started creating this DB.
On the continuous form, I am thinking about how all the records will show and how to filter those. Thus, I am looking to see if there is a code that I could use on a tick box=true event to hide all records where the status is "closed". I would appreciate all feedback on this.
 

Ranman256

Registered User.
Local time
Today, 12:28
Joined
Apr 9, 2015
Messages
3,773
in the afterupdate event of the checkbox

Code:
'----------------
sub chkFilter_afterupdate()
'----------------

If chkFilter Then
  Me.Filter = "[closed]=false"
  Me.FilterOn = True
Else
  Me.FilterOn = False
End If
end sub
 

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
in the afterupdate event of the checkbox

Code:
'----------------
sub chkFilter_afterupdate()
'----------------

If chkFilter Then
  Me.Filter = "[closed]=false"
  Me.FilterOn = True
Else
  Me.FilterOn = False
End If
end sub
Thanks for the code. I have just tried this and it isn't updating the records. Do you have any suggestions I can try?
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
Thanks for the code. I have just tried this and it isn't updating the records. Do you have any suggestions I can try?
Please show your code.
Just saying it does not work is as much use as a chocolate fireguard. :)
 

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
Please show your code.
Just saying it does not work is as much use as a chocolate fireguard. :)
The code is a direct copy of that supplied, no changes have been made. Information supplied twice is as much use as the chocolate kettle.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
The code is a direct copy of that supplied, no changes have been made. Information supplied twice is as much use as the chocolate kettle.
OK,
You state Status = "Closed" is the criteria you want to hide.?
So I would expect the filter would be along the lines of
Code:
Me.Filter = [Status] <> "Closed"
Me.FilterOn = True
Ranman256 gave you the logic, you need to adjust the names to suit?. That is why I was asking for the code.? :(
 

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
I do understand the methodology behind supplying the code, however, it didn't seem necessary to paste that I used directly.
So, I have pasted the code I have tested which doesn't seem to be working. Note that I have also tried on the click event
Code:
Private Sub ChkHideCLOSE_AfterUpdate()
    If chkFilter Then
    Me.Filter = [Status] <> "Closed"
    Me.FilterOn = True
Else
    Me.FilterOn = False
    End If
End Sub
 

Minty

AWF VIP
Local time
Today, 17:28
Joined
Jul 26, 2013
Messages
8,061
Pickling up on @Gasman 's point - we now we have the reason your code doesn't work.
Your check box is called ChkHideCLOSE . Your code is still referring to chkFilter;

Code:
Private Sub ChkHideCLOSE_AfterUpdate()
    If ChkHideCLOSE Then
    Me.Filter = [Status] <> "Closed"
    Me.FilterOn = True
Else
    Me.FilterOn = False
    End If
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
OK, your event is AfterUpdate of a control called ChkHideCLOSE
Yet you are checking chkFilter ??????

You need Option Explicit at the top of every module, be it Form, Report or Module.
You do this in the VBE window with Tools/Options Require Variable Declaration.
That will only work for new modules, so add that statement to all your modules.
 
Last edited:

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
Thank you for the replies. I have had no success so have build a sample DB for you to see.
Either I am really tired and cannot see it or just need another set of fresh eyes on this.
 

Attachments

  • EXTask.accdb
    960 KB · Views: 18

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
That is me out. I cannot read the table. :(
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
I can see the form in design mode, just cannot access the data. Says 14.0 is minimum needed.
 

Minty

AWF VIP
Local time
Today, 17:28
Joined
Jul 26, 2013
Messages
8,061
You were close - the filter is a string so you need to format it as such;

SQL:
Private Sub ChkHideCLOSE_AfterUpdate()
    If ChkHideCLOSE Then
    Me.Filter = "[Status] <> 'Closed'"
    Me.FilterOn = True
Else
    Me.FilterOn = False
    End If
End Sub

Apologies I should have spotted that first time around.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:28
Joined
Sep 21, 2011
Messages
7,793
You were close - the filter is a string so you need to format it as such;

SQL:
Private Sub ChkHideCLOSE_AfterUpdate()
    If ChkHideCLOSE Then
    Me.Filter = "[Status] <> 'Closed'"
    Me.FilterOn = True
Else
    Me.FilterOn = False
    End If
End Sub

Apologies I should have spotted that first time around.
As I should have. :unsure: Sorry about that. :(
 

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
Do you know what it is so clear now its been spotted. Its always the minor details! Thank you for the help in achieving this, both of you.
 

SparkieDEV

New member
Local time
Today, 17:28
Joined
Oct 13, 2020
Messages
26
of course, tiredness really did kick in! Thank you Ranman256
 

Users who are viewing this thread

Top Bottom