Calling a main forms text box's change event from a subform

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

I have a main form that includes a subform. On the update event of the
subform, I want to call the change event for a text box that exists on the
main form.

I have the following code but it errors out with an application defined or
object defined error...

Forms![frmPricing]![frmPricingDetail].Form.txtDiff_Change

(the main form I am referring to is in itself a subform - as you can see
above)

Any idea how I can call the change event of a text box on a different form?
I know I can get around this various other ways but it would be nice to know
anyway...

Thanks,

Brad
 
Brad said:
I have a main form that includes a subform. On the update event of the
subform, I want to call the change event for a text box that exists on the
main form.

I have the following code but it errors out with an application defined or
object defined error...

Forms![frmPricing]![frmPricingDetail].Form.txtDiff_Change

(the main form I am referring to is in itself a subform - as you can see
above)

Any idea how I can call the change event of a text box on a different form?
I know I can get around this various other ways but it would be nice to know
anyway...

What you need to know is that forms that are contained in subform
controls are not members of the Forms collection. They are properties
of the subform control. You have to first reference the Form the
subform control is on. Then the Subform control. Then the Form. Then
the control on the form.
 
try

Me.Parent.txtDiff_Change

in the *parent* form's module, make sure that the Change event procedure
starts with

Public Sub

rather than

Private Sub

hth
 
Back
Top