Solved

Access Code to Select All Records on a Form

Posted on 2013-01-24
5
919 Views
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!
0
Comment
Question by:Senniger1
  • 3
  • 2
5 Comments
 
LVL 75
ID: 38815543
How about this:

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

mx
0
 

Author Comment

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

Please advise.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 38815751
OOPS


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

Author Closing Comment

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

mx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now