Check box with "Select All" option....

Hassan

Registered User.
Local time
Today, 23:42
Joined
Feb 24, 2000
Messages
15
Hy!
I have a form based on query with lots of fields where one of them is a chech box field. Also I have a single check box (without control source) in form's header.

What I want is that when I select this single check box, all check boxes for all the records in the form turns to value = 1, (selected) and when I deselect that single check box, all check boxes for all the records in the form turns to value = 0 (deselected). Just like in Yahoo free mail account - option for selecting and deselecting all messages in one's inbox.

Problem is that I don't know how to make it work. Is there anybody who can help me?
Please!
 
Hassan,

You need to run an update query in the Click event of the unbound check box.

In the following code, the table being updated is "tblStaff". The field being updated is "User". And the unbound checkbox is called "chkAll".

Private Sub chkAll_Click()
'Turn off system warnings
DoCmd.SetWarnings (False)

If chkAll = True Then
'Run SQL update to check all records
DoCmd.RunSQL ("UPDATE tblStaff SET tblStaff.User = -1;")
Else
'Run SQL update to UNcheck all records
DoCmd.RunSQL ("UPDATE tblStaff SET tblStaff.User = 0;")
End If

'Refresh the records on the form
Me.Refresh

'Turn on system warnings
DoCmd.SetWarnings (True)
End Sub
 
Thank you Scottfarcus.
I guess that it must work. But I don't know why it still doesn't work. I am pretty sure I am doing something wrong, because I am a beginner in access. Maybe you can send me a sample database with this thing working?
 

Users who are viewing this thread

Back
Top Bottom