use command button to open subform

  • Thread starter Thread starter desperate
  • Start date Start date
D

desperate

Help!

Can anybody describe how to insert a command button on a
form that will open a subform whose records are specific
only to the main form's records? I don't want to clutter
up the main form with a visible subform.

Oh, and I am NOT familiar with code, so plain English is
appreciated.
 
You can use the command button wizard, following the prompts.

When you get to the prompt that asks: "Do you want the button to find
specific information to display in the form? Select the first option:
"Open the form and find specific data to display."

In the next prompt, identify the matching fields which will control the
selection and you have it.
 
Help!

Can anybody describe how to insert a command button on a
form that will open a subform whose records are specific
only to the main form's records? I don't want to clutter
up the main form with a visible subform.

Oh, and I am NOT familiar with code, so plain English is
appreciated.

Well, this really isn't a Subform, if you "open" it. I see three
options in increasing order of complexity, though they're all pretty
simple.

1. Use a Tab Control on the form, and put a Subform on the second page
of the tab. That way the user doesn't need to open anything, just
select the tab page.

2. If you've got lots of room on the Form, just set its Visible
property to False and have a button on the form; in that button's
Click event write code like

Private Sub cmdShowSub_Click()
Me!subformname.Visible = Not Me!subformname.Visible
End Sub

Clicking this button once will make the subform visible; clicking it
again will hide it.

3. Create a Query with

=Forms!yourmainform!controlname

as a criterion on the linking field, where controlname is the control
containing what would be the "master link field" on a subform. Base
your second ("sub") form on this query, and use the Command Button
wizard to open the subform.
 
Back
Top