Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reference Other Subforms (2003 SP3)

    I have a main form with multiple subforms and one one those I have code I want to use to manipulate controls another subform. It seems perfectly natural to have:

    Dim ResultsH As Form
    Set ResultsH = Me.Parent.Form_frmSectionH_Scans

    but it doesn't work.

    Does anyone know the correct syntax, please?

    Thanks

  2. #2
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Reference Other Subforms (2003 SP3)

    Set ResultsH = Me.Parent!ctlSbfScans.Form

    In place of ctlSbfScans (which I just made up), substitute whatever the name of the applicable subform control is on the parent form. (Note that the name of the subform control is probably not the same as the name of the subform itself.)

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference Other Subforms (2003 SP3)

    If I put

    Set ResultsH = Me.Parent!ctlSbfScans.Form

    (substituting the correct subform control name) I get an error saying can't find the field name referred to in the expression.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference Other Subforms (2003 SP3)

    Double check the name:
    - Open the main form in design view.
    - Click once on the second subform to select it.
    - Don't click on the subform twice, for that would select something in the subform.
    - If you do click in the subform again by accident, click outside it, then click on the subform again.
    - When you have selected the subform, you will see its name as a control on the main form in several places:
    - In the Object dropdown on the Formatting toolbar.
    - In the title bar of the Properties window.
    - In the Name property in the Other tab of the Properties window.
    - Use this name in the expression. If the name contains spaces or punctuation, enclose it in square brackets:

    Me.Parent![Subform Name].Form

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference Other Subforms (2003 SP3)

    I discovered the problem wasn't the naming as such but that I was using it in the event On Current to manipulate the other subform, which I guess could be a 'conflict of interest'. As soon as I used the code in a separate function it all worked perfectly. Thanks for all your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •