Making Check boxes work automatically

  • Thread starter Thread starter Kema
  • Start date Start date
K

Kema

On an Orders Database

Order Details is a subform of Orders

I track which ORDERS are complete with a Y/N
checkbox [OrderPrepared]on the Orders Form.

I also track which lines are complete
in ORDER DETAILS with a Y/N checkbox [LineComplete].

Obviously an order can not be complete without all lines
being completed.

I want the checkbox on Form![OrdersPrepared]to be checked
automatically when ALL [LineComplete] checkboxes in
OrderDetails have been checked for that order.

I also want the checkbox on Form![OrdersPrepared]to be
unchecked automatically when ANY [LineComplete] checkbox
in OrderDetails isunchecked for that order.

Additionally, I would like the program to prevent you
from checking the checkbox Form![OrdersPrepared] if any
[LineComplete] checkbox in OrderDetails is unchecked.


Thaks for the help.

..
 
There may be more elegant ways, but one way to accomplish
this is to disable the checkbox in the master form, and
only set it True or False in VBA by comparing the number
of detail records, using RecordsetClone.RecordCount,to the
number of boxes checked, using

=Abs(Sum([YourCheckBoxName]))

You can then set the master checkbox value from the detail
checkbox' AfterUpdate event:

Sub DetailCheckBox_AfterUpdate()
Dim intNumChecked As Integer
Dim intNRecords As Integer
...<set both variables>...
If intNumChecked = intNRecords Then
Forms!MasterFormName!MasterCheckBoxName = True
Else
Forms!MasterFormName!MasterCheckBoxName = False
End If
End Sub

HTH
Kevin Sprinkel
 
Back
Top