How do I clear all check boxes w/out manually unchecking boxes?

T

TJ

I have a database that contains client names and addresses. The database is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked if no
label is desired. How can I clear all check boxes without having to manually
uncheck the box in each row?
 
A

Allen Browne

Execute an Update query statement to reset the yes/no field to no for all
records.

This example assumes a table named Table1, with a field named MakeLabel. The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] = True;"
dbEngine(0)(0).Execute strSql, dbFailOnError
 
V

Van T. Dinh

I am not sure of your set-up but if the "CheckBox" is a Boolean Field in the
Source Table, you can clear all CheckBoxes (i.e. changing the Boolean Field
values from True to False) with an Update Query like:

UPDATE [YourTable]
SET [YourBooleanField] = False
WHERE [YourBooleanField] = True
 
T

TJ

This almost works. The last box that I check still does not get unchecked
when I run the procedure.

Allen Browne said:
Execute an Update query statement to reset the yes/no field to no for all
records.

This example assumes a table named Table1, with a field named MakeLabel. The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] = True;"
dbEngine(0)(0).Execute strSql, dbFailOnError

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

TJ said:
I have a database that contains client names and addresses. The database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
T

TJ

This clears all boxes in the field except the last box that was checked.

Van T. Dinh said:
I am not sure of your set-up but if the "CheckBox" is a Boolean Field in the
Source Table, you can clear all CheckBoxes (i.e. changing the Boolean Field
values from True to False) with an Update Query like:

UPDATE [YourTable]
SET [YourBooleanField] = False
WHERE [YourBooleanField] = True

--
HTH
Van T. Dinh
MVP (Access)


TJ said:
I have a database that contains client names and addresses. The database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
S

SusanV

Is the default value for the field set to checked? If so, changing it should
clear this up.

--
hth,
SusanV

TJ said:
This clears all boxes in the field except the last box that was checked.

Van T. Dinh said:
I am not sure of your set-up but if the "CheckBox" is a Boolean Field in
the
Source Table, you can clear all CheckBoxes (i.e. changing the Boolean
Field
values from True to False) with an Update Query like:

UPDATE [YourTable]
SET [YourBooleanField] = False
WHERE [YourBooleanField] = True

--
HTH
Van T. Dinh
MVP (Access)


TJ said:
I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
A

Allen Browne

That's because that change was not yet saved.

If you are running this is a bound form, force the save before executing the
string by adding this line above the others:
If Me.Dirty Then Me.Dirty = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

TJ said:
This almost works. The last box that I check still does not get unchecked
when I run the procedure.

Allen Browne said:
Execute an Update query statement to reset the yes/no field to no for all
records.

This example assumes a table named Table1, with a field named MakeLabel.
The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] =
True;"
dbEngine(0)(0).Execute strSql, dbFailOnError

TJ said:
I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
T

TJ

No it is not set to checked. There is a highlight around the last box that
is checked or unchecked, though.

SusanV said:
Is the default value for the field set to checked? If so, changing it should
clear this up.

--
hth,
SusanV

TJ said:
This clears all boxes in the field except the last box that was checked.

Van T. Dinh said:
I am not sure of your set-up but if the "CheckBox" is a Boolean Field in
the
Source Table, you can clear all CheckBoxes (i.e. changing the Boolean
Field
values from True to False) with an Update Query like:

UPDATE [YourTable]
SET [YourBooleanField] = False
WHERE [YourBooleanField] = True

--
HTH
Van T. Dinh
MVP (Access)


I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
T

TJ

When I do as you suggest, I receive a compile error - invalid use of me
keyword.

Allen Browne said:
That's because that change was not yet saved.

If you are running this is a bound form, force the save before executing the
string by adding this line above the others:
If Me.Dirty Then Me.Dirty = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

TJ said:
This almost works. The last box that I check still does not get unchecked
when I run the procedure.

Allen Browne said:
Execute an Update query statement to reset the yes/no field to no for all
records.

This example assumes a table named Table1, with a field named MakeLabel.
The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] =
True;"
dbEngine(0)(0).Execute strSql, dbFailOnError

I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
G

Garret

Why don't you just use VB code? Do:

[YourCheckbox1].value = 0
[YourCheckbox2].value = 0
[YourCheckbox3].value = 0
.....
and so on
When I do as you suggest, I receive a compile error - invalid use of me
keyword.

Allen Browne said:
That's because that change was not yet saved.

If you are running this is a bound form, force the save before executing the
string by adding this line above the others:
If Me.Dirty Then Me.Dirty = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

TJ said:
This almost works. The last box that I check still does not get unchecked
when I run the procedure.

:

Execute an Update query statement to reset the yes/no field to no for all
records.

This example assumes a table named Table1, with a field named MakeLabel.
The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] =
True;"
dbEngine(0)(0).Execute strSql, dbFailOnError

I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that is
checked if the user wants to print a label for the client and unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
S

SusanV

Are you doing the update with the form open? That would lock the record.
Also, is there a GotFocus event setting the checkbox to checked?

TJ said:
No it is not set to checked. There is a highlight around the last box
that
is checked or unchecked, though.

SusanV said:
Is the default value for the field set to checked? If so, changing it
should
clear this up.

--
hth,
SusanV

TJ said:
This clears all boxes in the field except the last box that was
checked.

:

I am not sure of your set-up but if the "CheckBox" is a Boolean Field
in
the
Source Table, you can clear all CheckBoxes (i.e. changing the Boolean
Field
values from True to False) with an Update Query like:

UPDATE [YourTable]
SET [YourBooleanField] = False
WHERE [YourBooleanField] = True

--
HTH
Van T. Dinh
MVP (Access)


I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that
is
checked if the user wants to print a label for the client and
unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
A

Allen Browne

If you used a bound form, and placed the code in the module of that form,
the Me refers to the form.

If you have placed the code in a different module, move it to the form's
module (the event procedure behind the button).

If you are using an unbound form, you will have to ensure the changes are
written before you execute the code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

TJ said:
When I do as you suggest, I receive a compile error - invalid use of me
keyword.

Allen Browne said:
That's because that change was not yet saved.

If you are running this is a bound form, force the save before executing
the
string by adding this line above the others:
If Me.Dirty Then Me.Dirty = False


TJ said:
This almost works. The last box that I check still does not get
unchecked
when I run the procedure.

:

Execute an Update query statement to reset the yes/no field to no for
all
records.

This example assumes a table named Table1, with a field named
MakeLabel.
The
code could go in the Click event procedure of a command button:

Dim strSql As String
strSql = "UPDATE [Table1] SET [MakeLabel] = False WHERE [MakeLabel] =
True;"
dbEngine(0)(0).Execute strSql, dbFailOnError

I have a database that contains client names and addresses. The
database
is
used to generate labels. I have a yes/no check box in each row that
is
checked if the user wants to print a label for the client and
unchecked
if
no
label is desired. How can I clear all check boxes without having to
manually
uncheck the box in each row?
 
Top