Solved Code required for hiding "[Status]=Closed" records on continuous forms

SparkieDEV

New member
Local time
Today, 17:55
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.
 
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
 
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?
 
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. :)
 
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.
 
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.? :(
 
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
 
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
 
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:
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

That is me out. I cannot read the table. :(
 
I can see the form in design mode, just cannot access the data. Says 14.0 is minimum needed.
 
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.
 
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. :(
 
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.
 

Users who are viewing this thread

Back
Top Bottom