Help with check box controlling sub form please

  • Thread starter Thread starter Darryn
  • Start date Start date
D

Darryn

I guess my earlier post was not really worthy of reply as I should
have done some more searching before I posted. I have since found out
about linked forms and are working on that one

At the moment I am also trying to implement a check box to control a
sub form. I want the user to check the box to bring up the subform
but keep it hidden if it is not needed. I have the following code in
the after update procedure for the check box

Private Sub chkboxKitItem_AfterUpdate()
If Me.chkboxKititem = True Then
Me.TblKitSubform.Visible = True
Else
Me.TblKitSubform.Visible = False
End If
End Sub

When I save the form and open it for data entry the check box has a
grey shading and the subform is visible, if I click the box it goes
checked another click then hides the subform.

I have tried setting the default data value of the check box to 0 but
it has no effect. What do I seem to be missing?

Darryn
-- remove two eyes to reply!
 
Set the Visible Property of the SubFormControl to No in the DesignView of
the (main) Form.

If you want, use the Form_Current Event to set the value of the CheckBox to
False / No / 0 on NewRec. I think the Default Value only applies to bound
Control on NewRec and your CheckBox sounds unbound to me.

You can shorten you code to:

Private Sub chkboxKitItem_AfterUpdate()
Me.TblKitSubform.Visible = Me.chkboxKititem
End Sub
 
Set the Visible Property of the SubFormControl to No in the DesignView of
the (main) Form.
Thanks that works great!
If you want, use the Form_Current Event to set the value of the CheckBox to
False / No / 0 on NewRec. I think the Default Value only applies to bound
Control on NewRec and your CheckBox sounds unbound to me.

You can shorten you code to:

Private Sub chkboxKitItem_AfterUpdate()
Me.TblKitSubform.Visible = Me.chkboxKititem
End Sub
I will play with those too

Thanks again

Darryn
-- remove two eyes to reply!
 
Back
Top