Automatic Checkboxes

S

Stephen

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.

Thaks for the help.
 
T

tina

the 2nd one should be easy enough (but with subforms you never know). in the
OrderDetails subform, on the LineComplete checkbox's AfterUpdate event, add
an event procedure with the following code, as

If Me!LineComplete = False Then
Me.Parent!OrderPrepared = False
End If

the first part is a little more involved. first, add an unbound control to
the OrderDetails subform's *footer section*, with its' Visible property set
to No. i'll call it txtSumIncompletes. set it's ControlSource to

=Sum(IIf([LineComplete] = True, 0, 1)

then change the above lines of code to

With Me
If .LineComplete = False Then
.Parent!OrderPrepared = False
ElseIf .txtSumIncompletes = 0 Then
.Parent!OrderPrepared = True
End If
End With

substitute the correct control names in all of the above, of course.
depending on the dynamics of how your form/subform is used, you may have to
run the code in other events besides the checkbox's AfterUpdate event.

hth
 

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