This tip will show you how to make a command button that checks all records using a check box that we will call [Include].
To do this:
Add a command button to the form without using the wizard, and then to the 'On Click' event add the following code (below the (***):
This code creates a copy of the records populating the form (recordsetclone). It then moves to the first record and changes the text box [Include] value to -1 (=True or Yes), it then moves to the next record and so on, until it reaches the end of the recordset (EOF = End Of File). The form is then re-queried so that the ticks are displayed in the check boxes.
*****************
On Error GoTo ErrorHandler
Dim db As Object
Dim rst As Object
Set db = Application.CurrentDb
Set rst = Me.RecordsetClone
rst.movefirst
Do Until rst.EOF
rst.edit
rst!Include = -1
rst.update
rst.movenext
Loop
Me.Requery
rst.Close
Exit Sub
ErrorHandler:
MsgBox "Error Number: " & err.Number & " " & err.Description
***************
Change Include to the name of your check box.
You may need to reference DAO, see the following:
Kirstie add a link for the following.
https://www.simply-access.com/ReferencingDAOAccess2000.html
Do you like this tip? Subscribe to my free weekly Newsletter to receive tips weekly via email. Click Here to subscribe.