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

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

Guest

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?
 
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 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
 
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?
 
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?
 
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?
 
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?
 
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?
 
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?
 
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?
 
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?
 
I agree with Allen that the record has not been saved, therefore it will not
be included in the update query. By simply adding the line 'RunCommand
acCmdSaveRecord' to your button click procedure before the query line and it
should solve the problem.



Allen 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
This almost works. The last box that I check still does not get unchecked
when I run the procedure.
[quoted text clipped - 21 lines]
 
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?
 

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

Similar Threads


Back
Top