?
Solved

Select all using a checkbox

Posted on 2011-02-24
13
Medium Priority
?
378 Views
Last Modified: 2012-05-11
I created 2 buttons a form to select and deselct all records on a subform, based on a checkbox.  When I select all records, the subform records are selected.  If I then deselect records, the code dosen't work, unless I exit the form and reopen.. Any suggestions ???
Private Sub SelectAllButton_Click()

    Dim db As Database
    Dim rs As DAO.Recordset
    
    Set db = CurrentDb
    Set rs = Forms![ContactMainF]![CertSubF].Form.RecordsetClone
    
    Do While Not rs.EOF
    rs.Edit
    rs!Print = True
    rs.Update
    rs.MoveNext
    Loop
    
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing
    
    
 Forms![ContactMainF]![CertSubF].Form.Requery
 

End Sub

Open in new window

0
Comment
Question by:ml-sd
[X]
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
  • 8
  • 5
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34971165
change this

Set rs = Forms![ContactMainF]![CertSubF].Form.RecordsetClone


with

Set rs = Forms![ContactMainF]![CertSubF].Form.Recordset
0
 

Author Comment

by:ml-sd
ID: 34971315
I tried that your comment, but after I run the code,  the subrecords were deleted ...?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34971331
what is the recordsource of the subform [CertSubF] ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ml-sd
ID: 34971414
yes
0
 

Author Comment

by:ml-sd
ID: 34971436

sorry i hit send to fast...  recordsource is certQ
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34971477
what is certQ? table or query? if query, post the sql view of the query.
0
 

Author Comment

by:ml-sd
ID: 34971504
crtq is a querey.  sql view attached

thanks
SELECT CertT.ID, CertT.MCDID, CertT.CertificateDate, CertT.CertificateComments, CertT.CertName, CertT.CertCompany, CertT.CertAddress1, CertT.CertAddress2, CertT.CertCity, CertT.CertState, CertT.CertZip, CertT.Print
FROM CertT
WHERE (((CertT.MCDID)=[Forms]![ContactMainF]![MCDID]));

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34971612
can you upload a copy of your db..

what is your intention on selecting all the records?
0
 

Author Comment

by:ml-sd
ID: 34971823
After the selection i am printing records...    i need to change the data to dummy data before sending,..
0
 

Author Comment

by:ml-sd
ID: 34972577
Heres the saple data  Thanks
Cert.mdb
0
 

Author Comment

by:ml-sd
ID: 34975587
I guess the question was harder than i thought :)
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 34976108
test this,

see the revised codes in the click event of the select and deselect buttons


Cert.mdb
0
 

Author Closing Comment

by:ml-sd
ID: 34976136
Awesome...   Thanks you so much.
I never would have figured that out.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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.
Suggested Courses

764 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