Hiding/showing subforms

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi, all

I have a form with a subform that I would like to be invisible until
required by the user. I have looked in the macros and been unable to find
anything that deals with subforms, and I've never used VBA before, so I seem
to be stuck. Does anybody know of a way to do this?

Thanks, David
 
Here is some code that you can put in the current event of the main form if
you want the subform to appear with a new record on the main form:

If Not IsNull(Me.YourMainFormID) Then
Me.YoursubfrmName.Visible = True

Else
Me.YoursubfrmName.Visible = False

End If

Another way, if you want the user to choose, would be to have a button on
the main form, and the click event would be similar to above :
Me.YoursubfrmName.Visible = True

Note that the subform is already on the mainform - at design level just set
its visible property to false

Damon
 
Back
Top