• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

Return the name of the active/with focus subform

Good afternoon

I am trying to return the name of the active form, where the form in question is a sub form. Code for example:
Set frmCurrentForm = Screen.ActiveForm

Using Screen.ActiveForm or Me when trying to return the name of a subform actually returns the name of the parent form. Is there a way to return the name of just the sub form? and is there away to name the parent forms seperately (especially if there are a number of nested subforms).


3 Solutions
True, using Screen.ActiveForm will display the parent, but from the subform itself, you can just us Me.name

Also check out this very handy page for references:
If the code is in the subform, then me.name will return the name of the subform.

If you are running code in a standard module you do things like:

Forms!orders1.ActiveControl.Name      to get the name of the subform control on th main form
Forms!orders1.ActiveControl.Form.Name     to get the name of the subform
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What, exactly, are you trying to do with the reference to your subform? A subform is actually a member of the Controls collection of the parent form, and you should always get a handel to the subform through the parentform, as peter suggests.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now