Show all records based on value in field

S

Secret Squirrel

I have a continuous form that lists all my employees. One of the fields on
the form is called "status". The value in that field can be either Active or
Inactive. I want to be able to put a checkbox on my form header and if it's
checked I want to requery my form and then show all records regardless of the
value in the status field and if it's not checked then only show the records
that have a value in the status field of "active". Any ideas?
 
L

Larry Linson

The code for the CheckBox's Click Event should replace the SQL in the Form's
Record Source with SQL that does not include a WHERE clause on the Status
field if the box has been checked, or replace it with SQL that does include
such a WHERE clause. If memory serves, when you replace the Record Source,
you will not need to Requery.

You can accomplish the same result using a Filter, but I prefer manipulating
the Record Source, as I find it simpler and that it does not exhibit some
"quirkiness" that I've encountered with Filters.

Larry Linson
Microsoft Office Access MVP
 
T

Tom van Stiphout

On Fri, 26 Sep 2008 19:10:01 -0700, Secret Squirrel

You don't have to requery. Simply apply a filter in the
MyCheckbox_AfterUpdate event:
(air code follows)
if MyCheckbox.Value = True then
Me.Filter = ""
Me.FilterOn = False
else
Me.Filter = "Status='Active'"
Me.FilterOn = True
end if

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top