uncheck and check checkbox.

G

Guest

Hi,

Part 1:I created a form with tabular layout view of everything in my table.
There are about 450 list on my form. I also have 450 checkbox one for each
item on the list. I would like to created a button when click once will fill
all the checkbox to Yes and click the same button again it will clear all the
checkbox from yes to no.

Part 2: If my user selected items they need on the list I want them to be
able filter that data using a button to show only the checked checkbox and
not the one that are unchecked. I would like the user to be able to create a
report on just the checked checkbox.
 
G

Guest

A checkbox is used in connection with a Yes/No field that stores data as a -1
(minus one) and 0 (zero).
Part 1: Put an option group with two check boxes in the header of your
form, one for all ALL CHECKED and one for ALL UNCHECKED. Set the On Change
property to run an update query to update your field based on the option
group data.
Part 2: Use a query with criteria of -1 for all checked.
 
G

Guest

Karl,

Is it not possible to have a button to do that? I've used some of the
posting with VB codes but it only works when I click on one checkbox and not
multiple checkboxes. So it will only undo the most recently checked checkbox
(only undo one) and not the others.
 
G

Guest

I've used Doug's code but it only undo check for one checkbox only instead of
the entire list of 450.


Won't it make more sense to use a button, not another checkbox?

Assuming you're going to uncheck every checkbox on the form, you need code
like:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is Checkbox Then
ctlCurr = False
End If
Next ctlCurr

If you ARE going to use a checkbox to kick this off, you'll probably want to
not uncheck the "trigger" checkbox, so you'd have something like:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is Checkbox Then
If ctlCurr.Name <> "chkUncheckAll" Then
ctlCurr = False
End If
End If
Next ctlCurr

If there are other checkboxes you don't want to impact, you'll need to come
up with some other way of identifying those checkboxes that you do want to
clear. One approach is to set the Tag property of those that you want to be
able to clear. Put something like "Clear" in that property, and use code
like:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is Checkbox Then
If ctlCurr.Tag = "Clear" Then
ctlCurr = False
End If
End If
Next ctlCurr

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



VB said:
please, help me to create checkbox on the for that will check/uncheck 20
other checkboxes on the same form.



Was this post helpful to you?
 

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