Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check/uncheck all check boxes. How to? 2

Status
Not open for further replies.

davejackson

Technical User
May 8, 2001
34
GB
Hi,

I have a form that is based over a table that is created from a make table query (So that the user can select records from a smaller number of records). One of the fields is a check box that is built over a yes/no field on the table. If the first query generates a lot of records, I would like the user to be able to select/deselect all the records at once using a check all button. Can anyone tell me how to do this please as I can only change one record at a time.

Thanks in advance,

Dave
 
You can run SQL to change the underlying tables values to Yes/No depending on the users selection. You will need an if statement to determine all on or all off and a requery to refresh the form. Here's the sample code:

[tt]
If MyCheckBox = -1 Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE MyTable SET MyTable.[YesNoField] = Yes;"
DoCmd.SetWarnings True
Me.Requery
Else
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE MyTable SET MyTable.[YesNoField] = No;"
DoCmd.SetWarnings True
Me.Requery
End If
[/tt]

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top