Clear Control method for records

A

AJ

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?
 
G

Graham Mandeno

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.
 
A

AJ

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?
 
Top