Hiding/showing subforms

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
 
D

Damon Heron

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
 

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