By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

multiple selection of check box

P: 2
I would like to know how i can make a multiple selection check box for e.g. like yahoo in box if you select or deselect the header check box all the below check boxes are checked or unchecked.

In access 2007 I have one form connected to one table with a field name Present and that field have check box Yes/No, if an employee is present i will check for him and if he is absent i will uncheck, it is big job if i have hundreds of employees to track their attendance, i have created on check box on the header of the form and i want to select or deselect all the check boxes when i select or deselect the header check box.

I would greatly appreciate if someone please help me on this

many thanks

best regards,
Apr 7 '10 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 100+
P: 2,321
You could connect an update query to the checkbox (or button). That is what I would do. Whether you want to do this by macro, or code, depends on your VBA skills.

If you need help with a VBA solution, you need to give some more information on your table structure, and your layout.
Apr 7 '10 #2

Expert 5K+
P: 8,636
Let's assume that your Main Check Box is named chkPresent. The following code, in the AfterUpdate() Event of chkPresent, will Check/Uncheck all Check Boxes on your Form depending on whether or not chkPresent is Checked. Is this what you are looking for?
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkPresent_AfterUpdate()
  2. Dim ctl As Control
  4. For Each ctl In Me.Controls
  5.   If ctl.ControlType = acCheckBox Then
  6.     If ctl.Name <> "chkPresent" Then
  7.       ctl.Value = Me![chkPresent].Value
  8.     End If
  9.   End If
  10. Next
  11. End Sub
Apr 8 '10 #3

P: 2
Dear Sir,
Foremost, many thanks for the prompt reply, i tryed this code in afterupdate event of my main checkbox but it checks only the cehck box which got the focus

here is my table sturcture design

StudentID - AutoNumber
StudentName - Text

would apprecaite again some more help on this

with kind and best regards,
Apr 8 '10 #4

Expert Mod 100+
P: 2,321
In the afterUpdate event of the checkbox:
Expand|Select|Wrap|Line Numbers
  1. Docmd.SetWarnings(False)
  2.   Docmd.Runsql("UPDATE tbl_Students SET TempAttendance = " & Me.ChckBox);
  3. Docmd.SetWarnings(True)
Note that this will set the TempAttendence field for ALL records in teh table. If you need to only do it for some records, you will need to add a WHERE clause.
Apr 8 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.