We help IT Professionals succeed at work.

Nested subforms. Need to refer to Main form-

scbdpm asked
Last Modified: 2008-07-13
I have a form on which there is a subform. On that subform is a second subform (nested subform?).

I need to refer to a field/control (the unique ID of the main form's current record) from the nested subform.

How can I do this?
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
The following Code Snippet might illuminate what happening.

Private Sub cmdSample_Click()
    Dim frmParent As Form
    Dim frmSub1 As Form
    Set frmSub1 = Me.Parent.Form
    Set frmParent = frmSub1.Parent.Form
    MsgBox frmParent.Controls("KeyID").Value
End Sub

Open in new window


This is very good and what I was looking for.

However, I was remiss in posting my entire solution I am seeking and therefore am having troubles translating.....

The reason I need this:
My DB captures customer encounters.

My main form is for each customer; demographicsl etc. The subforms on this form collect different pieces of data about that customer: contacts (meetings, phhone calls, etc).

The subform I am working on now is for data entry of an 'action item' pertaining to that customer.
on the 'action item' subform, my 'nested subform' is for collecting what product/service line the action item pertains to. On a different subform, we collect the product/service line the customer is currently involved in.

So, what I would like to do is, on the action item subform, there is a drop down 'service line'. From that drop down, I only want to see the product/service lines that the customer is part of.

As part of the Row Source for the combobox, I want to filter back to the customer that is displayed on the main form....

Have I totally confused the question now? LOL!

(can post another question if too complicated to answer here)


related question posted
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.