Solved

Access Code to Select All Records on a Form

Posted on 2013-01-24
5
967 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 - Microsoft MVP, Access and Data Platform) 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

821 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