Visible / Hide Subform based on entry into ComboBox

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

Guest

Hi,
I have a main form (TenderResults) which contains a ComboBox
(SchoolDeptPartners). I'd like a subform (SchoolDeptPartners) to appear if
the value of the ComboBox is =>1.
Please help a first time user :-)
Many thanks
Matv
 
Hi,
I have a main form (TenderResults) which contains a ComboBox
(SchoolDeptPartners). I'd like a subform (SchoolDeptPartners) to appear if
the value of the ComboBox is =>1.
Please help a first time user :-)
Many thanks
Matv

You'll need some VBA code to do this, in two events: the Form's
Current event (to set the visibility on or off as you move from record
to record) and in the AfterUpdate event of the combo
SchoolDeptPartners. You *will* need to change the name of either the
combo or the subform; they're both controls on the Form and cannot
have the same name. I'll assume that your combo is renamed to
cboSchoolDeptPartners and the Subform Control (not the form within it
but the box that contains the form) is sbfrmSchoolDeptPartners.
Something like

Private Sub Form_Current()
Me!sbfrmSchoolDeptPartners.Visble = (Me!cboSchoolDeptPartners >= 1)
End Sub

with the same line in the AfterUpdate event of the combo.

This is a bit sneaky - the logical expression in parentheses evaluates
to either TRUE or FALSE; and that value is then applied to the Visible
property of the subform control.

John W. Vinson[MVP]
 
Back
Top