Making Check boxes work automatically

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.

..
 
K

Kevin Sprinkel

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
 

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