Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2014
    Posts
    42
    Provided Answers: 1

    Unanswered: VBA Subform References

    Hey everyone,

    So I'm hoping that someone can shed some light on how to properly reference subforms in VBA. I have found this fantastic page for regular references, but I could use help translating it into VBA. I have tried quite a few iterations with no luck. For example, the code below works great in a query, but doesn't translate well into VBA.

    Code:
    ([Forms]![frmMainMenu]![NavigationSubform].[Form]![sfrReportPage].[Form]![cmboStatus]
    I've tried a myriad of combinations using Forms(), text similar to the code above, and other iterations, but no luck.

    Appreciate any insight.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Whan working in VBA, drop the square brackets:
    Code:
    Forms("frmMainMenu")!NavigationSubform.Form!sfrReportPage.Form!cmboStatus
    or using the full references:
    Code:
    Forms("frmMainMenu").Controls("NavigationSubform").Form.Controls("sfrReportPage").Form.Controls("cmboStatus")
    Be aware that the name of a control of type subform/subreport can be different from the name of the subform itself.
    Have a nice day!

  3. #3
    Join Date
    Jun 2014
    Posts
    42
    Provided Answers: 1
    Roger. I'll give it a shot in a bit. Appreciate the response.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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