Access Code to Select All Records on a Form

Posted on 2013-01-24
Last Modified: 2013-01-24
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!
Question by:Senniger1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 75
ID: 38815543
How about this:

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


Author Comment

ID: 38815741
When running the code I get a MS Access message "Update or CancelUpdate without AddNew or Edit.".

Please advise.
LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 38815751

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

Author Closing Comment

ID: 38815836
Perfect!  Many thanks!
LVL 75
ID: 38815860
You are welcome ... sorry for the confusion.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question