Display/Hide subform via command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to set up a main form that has a subform, but the subform is
not displayed unless someone clicks a button to open it?

If so, is it possible to do it so the detail section of the main form
essentially expands to accommodate the need for more space when the "display
subform" button is pressed (so that there's not a bunch of extra "blank"
space in the display of the main form in it's default (no subform visible)
display look?

PS: I have all my buttons down in the form footer if that's useful to know.

Thanks,
-CW
 
Button to hide the subform

Private Sub Button_Click()
Me.SubformName.Visible = False
End Sub

Or this hide the subform OnLoad

Private Sub Form_Load()
Me.SubformName.Visible = False
End Sub

Then use button to show the form
Private Sub Button_Click()
Me.SubformName.Visible = True
End Sub


Better still use a toggle option group to show or hide the sub
 
Thanks Wayne!

You rock.

-CW

Wayne-I-M said:
Button to hide the subform

Private Sub Button_Click()
Me.SubformName.Visible = False
End Sub

Or this hide the subform OnLoad

Private Sub Form_Load()
Me.SubformName.Visible = False
End Sub

Then use button to show the form
Private Sub Button_Click()
Me.SubformName.Visible = True
End Sub


Better still use a toggle option group to show or hide the sub
 
To make the toggle button.

Create a toggle button using the wizard and choose option buttons when
prompter.

Please this code behind the AfterUpdate event (change the name of the Frame
and the Subform)

Private Sub FrameName_AfterUpdate()
Select Case Me!FrameName
Case 1
Me. SubformName.Visible = True
Case 2
Me.SubformName.Visible = False
End Select
End Sub


Hope this was a help
 

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

Back
Top