How does one open a sub-form by clicking on a Command Button ?

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

Guest

I ask, as I can set up a sub-form on a form, but only want the sub-form to be
opened, when 2 combo-boxes have been selected. I can do this, and then open
a form - but cannot open it as a sub-form


Many thanks in advance
 
Do you actually need the subform not to be opened until the combo boxes are
selected, or would not seeing it do the trick? If the latter you could just
set the subform control's visible property to No, and make it visible in the
After Update event of the second combo box.
 
The subform can be hidden as you suggest, but I can't find the syntax to open
the subform. The subform is a datasheet view of a query, that is populated
when 2 combo-boxes are selected. At present, I can only get the form to open
one line at a time

Private Sub cmdShowInfo_Click()
DoCmd.OpenForm "Z-tblAuditorbyAudtistrial2with2 Subform"
End Sub

Are you saying have the sub-form open but hidden, and then show populated
when 2nd combo-box selected. Do you have any code for this ?


Many thanks in advance, Robert
 
I just tried your suggestion, and an error on the following entry in AFter
Update. is anything obviously wrong ?

=[Forms]![Z-tblAudits Subform - 2 buttons].Visible=Yes
 
A form and a subform work together because of a relationship that has been
established between fields in the underlying tables (or queries, which
inherit the same relationships as the tables on which they are based). You
would not open the subform with my suggestion, since it would already be
open, but would rather allow it to be seen.
The default name for the subform control is the name of the form. If you
gave the subform the name [Z-tblAudits Subform - 2 buttons], then the After
Update code in a combo box on the main form would be:
Me.Z-tblAudits Subform - 2 buttons.Visible = True
Any reference to subforms and subform controls assumes you have a proper and
functional relationship between your tables. I could probably be more
specific if I knew something about what your database does, and if I
understood the relationship behind the form/subform combination.


Robert G said:
I just tried your suggestion, and an error on the following entry in AFter
Update. is anything obviously wrong ?

=[Forms]![Z-tblAudits Subform - 2 buttons].Visible=Yes
--
Robert G


Robert G said:
The subform can be hidden as you suggest, but I can't find the syntax to open
the subform. The subform is a datasheet view of a query, that is populated
when 2 combo-boxes are selected. At present, I can only get the form to open
one line at a time

Private Sub cmdShowInfo_Click()
DoCmd.OpenForm "Z-tblAuditorbyAudtistrial2with2 Subform"
End Sub

Are you saying have the sub-form open but hidden, and then show populated
when 2nd combo-box selected. Do you have any code for this ?


Many thanks in advance, Robert
 
Back
Top