Check/uncheck

S

SandySun

Does anyone know how to create a check all or uncheck all command button?

I have bound checkboxes in my form (the number varies all the time depending
on the data)...what I would like to do, is when a user selects the check all
command once all checkboxes are checked off....two times will uncheck
everything. The command button would supersede any manually selected checks.

Any help is appreciated. Thanks!
 
J

John W. Vinson

Does anyone know how to create a check all or uncheck all command button?

I have bound checkboxes in my form (the number varies all the time depending
on the data)...what I would like to do, is when a user selects the check all
command once all checkboxes are checked off....two times will uncheck
everything. The command button would supersede any manually selected checks.

Any help is appreciated. Thanks!

What's the Recordsource of the form? The checkboxes must be bound to a Yes/No
field in some table; you can run an Update query to update the value of that
field, using some appropriate criteria. Are these multiple yes/no fields
within one record, or one yes/no field in multiple records?
 
S

SandySun

John, the form is bound to a table (salesforwk), and so is the check box
field(complete). The query (salesforwkq) shows daily sales. What I am
trying to do is create a master checkbox that would check all sales as
completed or all sales uncompleted....obviously the user can check each one,
however it would take to long. Any help is appreciated. Thanks!
 
J

John W. Vinson

John, the form is bound to a table (salesforwk), and so is the check box
field(complete). The query (salesforwkq) shows daily sales. What I am
trying to do is create a master checkbox that would check all sales as
completed or all sales uncompleted....obviously the user can check each one,
however it would take to long. Any help is appreciated. Thanks!

More clarification needed:

Do you want to check or clear the Complete yes/no field in every single record
in the entire table? every record for the week? every record displayed on the
form?

ASSUMING that you want to clear or check the value in every record returned by
salesforwkq, then make a copy of that query; let's call it ClearCheckwkq. This
would have the same criteria as salesforwkq, but would only include the single
field [complete]. Change it to an Update query updating complete to

=Forms![yourformname]![yourmastercheckboxname]

and execute the query in the AfterUpdate event of the checkbox.
 
S

SandySun

John, I had used something liek this before...but it doesn't seem to
work...any suggestions?

Private Sub Check98_Click()
Me! salesforwkq.Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Edit
Me![check] = Me!Check98
.Update
.MoveNext
Loop
End If
End With
End Sub


John W. Vinson said:
John, the form is bound to a table (salesforwk), and so is the check box
field(complete). The query (salesforwkq) shows daily sales. What I am
trying to do is create a master checkbox that would check all sales as
completed or all sales uncompleted....obviously the user can check each one,
however it would take to long. Any help is appreciated. Thanks!

More clarification needed:

Do you want to check or clear the Complete yes/no field in every single record
in the entire table? every record for the week? every record displayed on the
form?

ASSUMING that you want to clear or check the value in every record returned by
salesforwkq, then make a copy of that query; let's call it ClearCheckwkq. This
would have the same criteria as salesforwkq, but would only include the single
field [complete]. Change it to an Update query updating complete to

=Forms![yourformname]![yourmastercheckboxname]

and execute the query in the AfterUpdate event of the checkbox.
 
J

John W. Vinson

John, I had used something liek this before...but it doesn't seem to
work...any suggestions?

"Doesn't work" is a bit vague. What is happening? I did see some errors:
Private Sub Check98_Click()
Me! salesforwkq.Form.RecordsetClone

This line above should probably be

With Me!salesforwkg.Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Edit
Me![check] = Me!Check98
.Update
.MoveNext
Loop
End If
End With
End Sub

Much better in any case would be an Update Query using the same criteria as
your master/child link field.
 
S

SandySun

I see.

Well I decided to go with an update query.....not the choice I prefer, as
the form is continuous, I don't think there are going to be other options.
Is that correct John?

John W. Vinson said:
John, I had used something liek this before...but it doesn't seem to
work...any suggestions?

"Doesn't work" is a bit vague. What is happening? I did see some errors:
Private Sub Check98_Click()
Me! salesforwkq.Form.RecordsetClone

This line above should probably be

With Me!salesforwkg.Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Edit
Me![check] = Me!Check98
.Update
.MoveNext
Loop
End If
End With
End Sub

Much better in any case would be an Update Query using the same criteria as
your master/child link field.
 
J

John W. Vinson

I see.

Well I decided to go with an update query.....not the choice I prefer, as
the form is continuous, I don't think there are going to be other options.
Is that correct John?

Well, the data is NOT in the form; it's in the table, so in order to update
multiple records you need to update the table (one way or another). I wouldn't
say that it's impossible to do it on the form, but the update query is
probably by far the simplest choice.
 
S

SandySun

Ok.....Thanks John. Easier is always better!

John W. Vinson said:
Well, the data is NOT in the form; it's in the table, so in order to update
multiple records you need to update the table (one way or another). I wouldn't
say that it's impossible to do it on the form, but the update query is
probably by far the simplest choice.
 

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

Top