tick all check boxs with one click

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

Guest

I have a Form called "Paid". Within the Form I have a Subform called
"Paidsubform". What I would like to do is Check one box on the Form and this
to be applied on all the records on the Subform.
 
Kirt84 said:
I have a Form called "Paid". Within the Form I have a Subform called
"Paidsubform". What I would like to do is Check one box on the Form
and this to be applied on all the records on the Subform.

I have not tried it, but why not add that field from the parent table to
the subform? If you are trying to store the results to the subform it
likely should not be done.
 
Kirt84,

Try designing an update query that will update the appropriate field in the
appropriate table. Then in the AfterUpdate event of your checkbox on your
main form, just use code to execute the update query. It is possible to have
this same code to update the same records when the checkbox is unchecked.
 
Untested but should work .

Assuming The check box on your form name is "TickAll" On YourForm
This will Tick All check boxed in sub form If the one on the main Form is
ticked *but* will not change existing ticks on the subform if the the check
box on the main form is unticked.


Private Sub TickAll_AfterUpdate

Dim strForm as string, strSubForm as str, StrPaid as str,

If Not Me.TickAll then
exit sub
Endif

strForm= "Paid"
strSubForm= "PaidSubForm"
strPaid="the paid Check Box on your subform"

DoCmd.GoToControl strSubForm
Form(strForm)(strSubForm).SetFocus 'Note: Form in singular
DoCmd.GoToRecord , , acFirst

DO
If Forms(strForm)(StrSubForm).Form.NewRecord Then
Exit Do
End If
'Above assumes that your subform *allows additions*

Forms(strForm)(strSubForm)(strPaid)=True
DoCmd.GoToRecord , , acNext
Loop

DoCmd.SelectObject acForm, strForm
DoCmd.GoToControl "TickAll"

End Sub

Regards/JK
 
Kirt84 said:
Not sure what you mean by this

OK let's say you have a table for employees. Now you want to have a
table for divisions. Each employee must work for one and only one division.
Some divisions are local and some are not.

As I understand it your form would be the division and the subform would
be the employees. You want a check mark for each employee who works for a
division that is local and no check mark for those who work for non-local
divisions.

You want to check mark the division and then have each employee check
marked. Normally you would not do it that way. You apparently already have
related the employee to a division so rather than add a check mark for each
employee, you should just refer to the check mark for the division. You can
show that divisions check mark on an employee's form by inserting the
division's check box.

Access works better this way and in the event that one division moves
and becomes a non-local division, all the check marks change totally
automatically, never an error of missing one.
 
Excellent this works!! Is there a way of unticking the Main box on the Form
and this then being applied to the Subform boxes. This would be great if
there is a way of doing this!!! Thank very much.
 
Yes there is Kirk

Working on the previouse Sub follow the notes (starting with ' and ending
with ******)

+++++++
Private Sub TickAll_AfterUpdate

Dim strForm as string, strSubForm as str, StrPaid as str, IsTicked as
Boolean 'Add Var "IsTiched " *****


' Remove If Statement from here *********

strForm= "Paid"
strSubForm= "PaidSubForm"
strPaid="the paid Check Box on your subform"
IsTicked=Me.TickAll 'Add This Line *******

DoCmd.GoToControl strSubForm
Form(strForm)(strSubForm).SetFocus 'Note: Form in singular
DoCmd.GoToRecord , , acFirst

DO
If Forms(strForm)(StrSubForm).Form.NewRecord Then
Exit Do
End If
'Above assumes that your subform *allows additions*

Forms(strForm)(strSubForm)(strPaid)=IsTicked 'Change "True" to
"IsTicked " ******
DoCmd.GoToRecord , , acNext
Loop

DoCmd.SelectObject acForm, strForm
DoCmd.GoToControl "TickAll"

End Sub
+++++++++++
(4 changes in all)

Regards/JK
 
Back
Top