Solved

Access Code to Select All Records on a Form

Posted on 2013-01-24
5
945 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

813 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

19 Experts available now in Live!

Get 1:1 Help Now