Checkbox controls subform visibility - how to keep it visible when form is reopened?

1.1k views Asked by At

A checkbox controls whether a subform is visible. If the checkbox is "true," the subform is visible. The problem is, when I close and reopen the form the subform is no longer visible even though the checkbox is still true. I have to uncheck and re-check the checkbox before the subform becomes visible again. Here's what I'm using:

Private Sub RefBoardCkbx_Click()
If RefBoardCkbx.Value = True Then
[Admin Sep - Awaiting Prelim SubBox].Visible = True
Else
[Admin Sep - Awaiting Prelim SubBox].Visible = False
End If
End Sub

Obviously, there has to be some way for the form to automatically re-run the code everytime it opens--I don't know how to make it do that!

1

There are 1 answers

3
HansUp On

Use the main form's On Load event to make the subform visible when the form opens.

Me.[Admin Sep - Awaiting Prelim SubBox].Visible = True

You probably also want to put a check in the check box at the same time.

Me.RefBoardCkbx.Value = True

As a side point, consider whether this version of the click event procedure makes sense to you ...

Private Sub RefBoardCkbx_Click()
    Me.[Admin Sep - Awaiting Prelim SubBox].Visible = Me.RefBoardCkbx.Value
End Sub