dbTalk Databases Forums  

Checkbox to limit records

comp.databases.ms-access comp.databases.ms-access


Discuss Checkbox to limit records in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
WhathaveIdone?
 
Posts: n/a

Default Checkbox to limit records - 09-14-2010 , 05:23 PM






I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a checkbox)
When chkShowDiscontinued = False, I want to show records where
chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce this
idea off several people to see if anyone has any better ideas for
making it work. None of mine have worked so far. Not 100% anyway and
I'm tired of dealing with it.

WhathaveIdone?

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Checkbox to limit records - 09-14-2010 , 06:28 PM






WhathaveIdone? wrote:

Quote:
I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a checkbox)
When chkShowDiscontinued = False, I want to show records where
chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce this
idea off several people to see if anyone has any better ideas for
making it work. None of mine have worked so far. Not 100% anyway and
I'm tired of dealing with it.

WhathaveIdone?
What's your filter?

Similar to
Select ... From ... Where chkDiscontinued =
Forms!YourFormName!chkShowDiscontinued
?

If for a form, you can do something like
Me.Filter = (chkDiscontinued = Me.chkShowDiscontinued)
Me.FilterOn = True
if you want to set it when the checkbox is checked.

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Checkbox to limit records - 09-14-2010 , 06:35 PM



On 14/09/2010 23:23:16, "WhathaveIdone?" wrote:
Quote:
I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a checkbox)
When chkShowDiscontinued = False, I want to show records where
chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce this
idea off several people to see if anyone has any better ideas for
making it work. None of mine have worked so far. Not 100% anyway and
I'm tired of dealing with it.

WhathaveIdone?

Query behind the form should be something like - OK I Mean ProductForm
RecordSource "SELECT tblProducts.* FROM tblProducts WHERE chkDiscontinued = "
& Forms!ProductForm!chkShowDiscontinued & ";"

on the AfterUpdate of the chkShowDiscontinued, I think you will need
Me.Requery

Phil

Reply With Quote
  #4  
Old   
John Spencer
 
Posts: n/a

Default Re: Checkbox to limit records - 09-15-2010 , 08:27 AM



Field: chkDiscontinued
Criteria: Forms!frmProducts!chkShowDiscontinued OR
(Forms!frmProducts!ChkShowDisContinued=True)

In query design view
-- Enter Forms!frmProducts!ChkShowDisContinued in a blank FIELD "box".
-- Criteria (line 1): True
Criteria (line 2) : leave it blank

For chkDiscontinued field set it up this way
Field: chkDiscontinued
Criteria (line 1): Leave it blank
Criteria (line 2) : Forms!frmProducts!chkShowDiscontinued


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

WhathaveIdone? wrote:
Quote:
I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a checkbox)
When chkShowDiscontinued = False, I want to show records where
chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce this
idea off several people to see if anyone has any better ideas for
making it work. None of mine have worked so far. Not 100% anyway and
I'm tired of dealing with it.

WhathaveIdone?

Reply With Quote
  #5  
Old   
WhathaveIdone?
 
Posts: n/a

Default Re: Checkbox to limit records - 09-15-2010 , 01:11 PM



On Sep 15, 7:27*am, John Spencer <JSPEN... (AT) Hilltop (DOT) umbc> wrote:
Quote:
Field: chkDiscontinued
Criteria: Forms!frmProducts!chkShowDiscontinued OR
(Forms!frmProducts!ChkShowDisContinued=True)

In query design view
-- Enter Forms!frmProducts!ChkShowDisContinued in a blank FIELD "box".
-- Criteria (line 1): True
* * Criteria (line 2) : leave it blank

For chkDiscontinued field set it up this way
Field: chkDiscontinued
Criteria (line 1): Leave it blank
Criteria (line 2) : Forms!frmProducts!chkShowDiscontinued

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County



WhathaveIdone? wrote:
I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a checkbox)
When chkShowDiscontinued = False, I want to show records where
chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce this
idea off several people to see if anyone has any better ideas for
making it work. None of mine have worked so far. Not 100% anyway and
I'm tired of dealing with it.

WhathaveIdone?
Good ideas everyone. Thanks John. Your solution was bay far the
simplest and easiest. Worked like a charm. I just added a requery
function to the chkDiscontinued AfterUpdate(), and it was perfect.
EXACTLY what I needed. Thanks for showing the simplest answer on that!

-WhathaveIdone?

Reply With Quote
  #6  
Old   
David W. Fenton
 
Posts: n/a

Default Re: Checkbox to limit records - 09-15-2010 , 09:50 PM



"WhathaveIdone?" <brasus04 (AT) gmail (DOT) com> wrote in
news:da90f977-59f4-4d5b-a891-5a0ec3dd3a89 (AT) x18g2000pro (DOT) googlegroups.co
m:

Quote:
I have an unbound checkbox on a form and I would like to limit the
records based on the checkbox. Here's the data:
Form: frmProducts
Table behind form: tblProducts
unbound checkbox: chkShowDiscontinued
Dependent field from table and form: chkDiscontinued (also a
checkbox) When chkShowDiscontinued = False, I want to show records
where chkDiscontinued = false
When chkShowDiscontinued = True, I want to show all the records
recordcount = hundreds of records

I have done this in several different ways and I wanted to bounce
this idea off several people to see if anyone has any better ideas
for making it work. None of mine have worked so far. Not 100%
anyway and I'm tired of dealing with it.
I have a UI philosophy about this kind of thing that is perhaps a
bit strange, but it comes about from confusion on the part of users
as to what I meant by checkbox filters like this.

A checkbox would turn on/off display of certain records.

While there are only two states to the checkbox, True or False,
i.e., checked or unchecked, there are actual three sets of data that
might be useful to the users:

1. all records.

2. discontinued only.

3. the data set EXCLUDING discontinued records.

While you don't say your users need 3, the problem is wording the
label on the checkbox so that it is clear what the result is when
you uncheck it. "Hide discontinued" may be sufficient, but not
necessarily -- depends on what it means and how your users interpret
it.

So, I usually do these with an option group, with the default being
whichever of the three choices is the most common. You can save
space by using a combo box for that, if necessary, but I like having
the choices visible all at once.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.