referencing for subforms

  • Thread starter Thread starter Don B
  • Start date Start date
D

Don B

I have a command button on a subform on the first page of a tab control which
is on the active form. I want to control the visability of the command
button based on a combo box selection on the active form. I can't seen to
get the syntax right for referencing the command button.
 
Don B said:
I have a command button on a subform on the first page of a tab control
which
is on the active form. I want to control the visability of the command
button based on a combo box selection on the active form. I can't seen to
get the syntax right for referencing the command button.

Me.SubformControlName.Form.CommandButtonName.Visible = ...

The .Form bit is probably what you're missing. Without that you're referring
to the subform control, which *contains* the form containing the button.
 
MainForm.NameofControlContainingSubform.Form.NameofCommandButton

If you created the subform control via drag-and-drop, the wizard probably
used the subform name for the NameofControlContainingSubform as well. This
can be very confusing as the difference is important. (I always make sure my
subform controls do *not* share the same name as my subforms.)

http://mvps.org/access/forms/frm0031.htm
Forms: Refer to Form and Subform properties and controls

Also:
Any controls on a Tab control are considered to be on the same form as the
Tab control (i.e., being on a Tab doesn't have any affect on how a control
is referenced. The Tab is irrelevant as far as coding is concerned).
 
Back
Top