Link to home
Start Free TrialLog in
Avatar of ml-sd
ml-sdFlag for United States of America

asked on

Select all using a checkbox

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

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

change this

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


with

Set rs = Forms![ContactMainF]![CertSubF].Form.Recordset
Avatar of ml-sd

ASKER

I tried that your comment, but after I run the code,  the subrecords were deleted ...?
what is the recordsource of the subform [CertSubF] ?
Avatar of ml-sd

ASKER

yes
Avatar of ml-sd

ASKER


sorry i hit send to fast...  recordsource is certQ
what is certQ? table or query? if query, post the sql view of the query.
Avatar of ml-sd

ASKER

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

can you upload a copy of your db..

what is your intention on selecting all the records?
Avatar of ml-sd

ASKER

After the selection i am printing records...    i need to change the data to dummy data before sending,..
Avatar of ml-sd

ASKER

Heres the saple data  Thanks
Cert.mdb
Avatar of ml-sd

ASKER

I guess the question was harder than i thought :)
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ml-sd

ASKER

Awesome...   Thanks you so much.
I never would have figured that out.