Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access Code to Select All Records on a Form

Posted on 2013-01-24
5
Medium Priority
?
1,162 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

782 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