Solved

Select all using a checkbox

Posted on 2011-02-24
13
367 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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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 250 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

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
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.

778 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