Clear Control method for records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a check box called "select" on my form so that the user can select the
record or multiple records to show on a report. I need to be able to click on
a button cmdClear and it clear all of the check boxes called "select" for
each record. I can get the command button to deselect one records check box,
but not multiple.

Is this possible?
 
Hi AJ

Reading between the lines here, I assume that your "Select" checkbox is
bound to a "Select" in your underlying table.

If this is the case, then you need to run an update query to "clear" the
selection. Something like this:

Private Sub cmdClear_Click()
dim DB as DAO.Database
Set db = CurrentDb
db.Execute "Update [YourTable] set [selected]=0 where [selected]<>0",
dbFailOnError
MsgBox db.RecordsAffected & " records have been deselected"
Set db = Nothing
End Sub

Of course, the MsgBox is optional.
 
Thank you! I will try that right now.

Graham Mandeno said:
Hi AJ

Reading between the lines here, I assume that your "Select" checkbox is
bound to a "Select" in your underlying table.

If this is the case, then you need to run an update query to "clear" the
selection. Something like this:

Private Sub cmdClear_Click()
dim DB as DAO.Database
Set db = CurrentDb
db.Execute "Update [YourTable] set [selected]=0 where [selected]<>0",
dbFailOnError
MsgBox db.RecordsAffected & " records have been deselected"
Set db = Nothing
End Sub

Of course, the MsgBox is optional.
--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

AJ said:
I have a check box called "select" on my form so that the user can select
the
record or multiple records to show on a report. I need to be able to click
on
a button cmdClear and it clear all of the check boxes called "select" for
each record. I can get the command button to deselect one records check
box,
but not multiple.

Is this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top