Access Code to Select All Records on a Form

In Access 2010 I have a Continuous Form named frmFilter.

When I open the form, it shows some filtered records.  Each record has a checkbox field named ckbComplete.  

In the form header I have a command button named cmdSelectAll and I'm trying to code it to select all the records on this form.

Here's my code by code but it only selects one record which is the record that has the focus.

    Dim ctl As Control
      For Each ctl In Me.Controls
        Select Case ctl.ControlType
          Case acCheckBox
            ctl = True
        End Select
      Next ctl

How can this be coded to put a check in the box of all records on this form?

Thanks in advance!
Senniger1Asked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
OOPS


 With Me.RecordsetClone
    Do
        .Edit
        ![YourCheckBoxFieldName] = True
         .Update
        .MoveNext
    Loop Until .EOF
 End With
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
How about this:

 With Me.RecordsetClone
    Do
        ![YourCheckBoxFieldName] = True
        .MoveNext
    Loop Until .EOF
 End With

mx
0
 
Senniger1Author Commented:
When running the code I get a MS Access message "Update or CancelUpdate without AddNew or Edit.".

Please advise.
0
 
Senniger1Author Commented:
Perfect!  Many thanks!
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome ... sorry for the confusion.

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.