Hiding subforms

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

Guest

How do I hide a subform based on a value on the main form (or other subform
on the same form)? Thanks.
 
dia said:
How do I hide a subform based on a value on the main form (or other subform
on the same form)?

"Hide" usually means making it invisible.

Me.subformcontrol.Visible = (Me.othercontrol = somevalue)
 
try

If Me!MainFormControl = "some value" Then
Me!SubformControlName.Visible = False
Else
Me!SubformControlName.Visible = True
End If

or, the same code in shorter form

Me!SubformControlName.Visible = Not (Me!MainFormControl = "same value")

(the above is a single line.)

if the value may be already present on the current record, put the code in
the form's Current event procedure. if the value may be changed in the
current record by the user, put the code in the AfterUpdate event procedure
of the control where the value is stored.

hth
 
Back
Top