Hide specific records with a check-box

randle

Registered User.
Local time
Today, 23:28
Joined
Jun 16, 2010
Messages
57
Hi

I have an inventory database with a main form that has a field called "Status". I simply want a check-box on this form that will filter out a specific status ie. "Dead" from view. Nice and simple yet I can't seem to find straight forward instructions on how to do something that should really be so simply. I'm learning as I go along so please be gentle ;)
 
You don't need a check-box, simply exclude a records with "Dead" in the field "Status".
 
I'm aware of this but want it to default the view every time it's opened to not show this and want a quick toggle between the Two views which is why I wanted to use a check-box
 
Send a short example of your mdb, (access 2000, or 2002, or 2003, ziped).
 
It's an Access 2007 database. I've attached a cut down version which hopefully will be of some use.

Many thanks
 

Attachments

create two queries, one with "Dead" and the other without.

use the AfterUpdate evnet of the checkbox to change the RecordSource for the combo, and requry the combo
 
I would use a Query, but I think something like this might work.

Code:
Private Sub CheckBox_AfterUpdate()
If Me.CheckBox = True Then
      run some filter 
ElseIf Me.CheckBox = False Then
       unfilter
End If
 
End Sub
 
1) I have said "a short example", but you sent 972 kb.
2) I improvise something, look at attachment (ziped).
3) It can be done via 2 queries too, as SMIG said.
4) Open Form1 and try (look at VBA).
 

Attachments

Thanks for the replies. I was under the impression that was a short example of my actual database as removed almost all records!!

The demo db you sent does exactly what I want but attempting to integrate it into my actual db gave me errors that I just couldn't figure out however I managed to get this working by using the following code
Private Sub Check153_Click()
On Error GoTo Check153_Click_Err
If (Check153 = 0) Then
DoCmd.ApplyFilter "", "[StatID]<>4"
End If
If (Check153 = -1) Then
DoCmd.ApplyFilter "", """"""
End If

Check153_Click_Exit:
Exit Sub
Check153_Click_Err:
MsgBox Error$
Resume Check153_Click_Exit
End Sub
This does exactly what I'm after so am pretty happy now.

I had previously thought of using a queries but didn't want to have to make changes to multiple forms evey time I wanted to change the layout!!
 

Users who are viewing this thread

Back
Top Bottom