Can't access multiple levels of children/parents in Datasheet Form views RRS feed

  • Question

  • I've created parent/child-related forms that go down a few levels. When they are all in form view, I can use the top form module to access the lowest form module in VBA and from lowest I can reference the top parent. But when I change the forms to Datasheet View, I lost this functionality. For example while all are in Form view this works, but all forms in DS view this won't work:

    Debug.Print Me.Parent.Form.Parent.Form.Name

    Debug.Print Me.child.Form.child.Form.Name
    • Edited by HTHP Thursday, January 14, 2016 1:56 PM
    Thursday, January 14, 2016 1:55 PM

All replies

  • Hi. I did some quick testing and what I found out was you "must" activate the subdatasheet control of the form first before you can refer to the child property. Which event were you using for your code?

    Thursday, January 14, 2016 4:55 PM
  • I have 3 forms. Parent>Child>Child. I tried using the bottom child's Current Event as a test to debug.print Me.Parent.Form.Parent.Form.Name
    I also tried the reverse, clicking on the top form(Datasheet view on all of course) to have it's Current Event trying to debug.print

    both gave errors.
    Thursday, January 14, 2016 7:27 PM
  • Hi. Does it work if you do it for the middle child? Here's what my setup look like:

    Datasheet form with one subform.

    Here's the Current event code.

    Here's the result.

    Thursday, January 14, 2016 7:38 PM
  • I modified my form to add a sub-subform, and here's the result:

    Datasheet form with sub-subform.

    Current event code for sub-subform.

    Immediate window result.

    Thursday, January 14, 2016 7:58 PM