Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Update Control In One Subform From Another Subform

Posted by: esturgesjr Jul 17 2019, 08:51 PM

What seemed to be a rather simple action has me completely bewildered!

I have a form (frmSponsors) with a Tab Control containing four subforms. Each subform is tied to the main with Master/Child IDs.

Now for the dilemma! I have a control on sfrmPKG called PkgID. I want an AfterUpdate Event on PkgID to update the control on sfrmWording (also PkgID) with the same value. No matter how I reference the 2nd subform, the VBA stops and tells me it can't find sfrmWording (the last attempt was: Me!sfrmWording.Form!PkgID = Me.PkgID).

Can someone shed some light, please?

Posted by: GroverParkGeorge Jul 17 2019, 09:13 PM

The reference needs to be to the name of the subform CONTROL, which may or may not be the same as the name of the subform in that control. Make sure that is how your reference is written.

Posted by: dale.fye Jul 18 2019, 05:50 AM

Since your PkgID is being entered in a subform, you need to reference the main form. You should be able to do this with:

[MainFormName]![sfrmWording]!Form.PkgID = me.PkgID

or with

me.Parent.sfrmWording.Form.PkgID = me.PkgID

and "sfrmWording" should be replaced with the name of the subform control (which may not be the same as the source object for that control).

For example, I generally rename my subform controls with a prefix of "sub_", so in my database the subform control name might be "sub_Wording"

Posted by: esturgesjr Jul 18 2019, 08:24 AM

Thank you, Grover Park George and dale.fye for your quick response. me.Parent.sfrmWording.Form.PkgID = me.PkgID did the trick!

I am forever indebted to UA for all that I've learned over the years and whenever I stumble, you guys/gals are here to pick me up and get me on my way again!

Thank you! Thank you! THANK YOU!