• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

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

0
ml-sd
Asked:
ml-sd
  • 8
  • 5
1 Solution
 
Rey Obrero (Capricorn1)Commented:
change this

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


with

Set rs = Forms![ContactMainF]![CertSubF].Form.Recordset
0
 
ml-sdAuthor Commented:
I tried that your comment, but after I run the code,  the subrecords were deleted ...?
0
 
Rey Obrero (Capricorn1)Commented:
what is the recordsource of the subform [CertSubF] ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ml-sdAuthor Commented:
yes
0
 
ml-sdAuthor Commented:

sorry i hit send to fast...  recordsource is certQ
0
 
Rey Obrero (Capricorn1)Commented:
what is certQ? table or query? if query, post the sql view of the query.
0
 
ml-sdAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
can you upload a copy of your db..

what is your intention on selecting all the records?
0
 
ml-sdAuthor Commented:
After the selection i am printing records...    i need to change the data to dummy data before sending,..
0
 
ml-sdAuthor Commented:
Heres the saple data  Thanks
Cert.mdb
0
 
ml-sdAuthor Commented:
I guess the question was harder than i thought :)
0
 
Rey Obrero (Capricorn1)Commented:
test this,

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


Cert.mdb
0
 
ml-sdAuthor Commented:
Awesome...   Thanks you so much.
I never would have figured that out.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now