ACC97: Previous/ActiveControl Name Property Not in Auto List

Last reviewed: October 16, 1997
Article ID: Q175216
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. However, if you type Screen.ActiveControl or Screen.PreviousControl in a module or the Debug window to view the properties that you can apply from the Auto List Members list, the Name property does not appear on the list.

RESOLUTION

To refer to the Name property of the Screen.ActiveControl or Screen.PreviousControl, you should create a variable and assign the name of the control to that variable. For example, the following sample piece of code is one way you could refer to the active control's name:

   Dim ctlCurrentControl As Control

   Set ctlCurrentControl = Screen.ActiveControl

     If ctlCurrentControl.Name = "txtCustomerID" Then

            ' Do this.

     ElseIf ctlCurrentControl.Name = "btnCustomerDetails" Then

           ' Do this.

     End If

WARNING: Code that refers to Screen.ActiveControl or Screen.ActiveForm will not work correctly when called from the Debug window because the Debug window has the focus at that time. If no control has the focus when you use the Screen.ActiveControl property, or if all of the active form's controls are hidden or disabled, a run-time error will occur. Use the Me object instead of the ActiveControl property in Event procedures.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open a new database in Microsoft Access 97 and create a new module.

  2. Type the following procedure in the module:

          Dim CControl as Control
          Set CControl = Screen.ActiveControl.
    

    Note that the Name property does not appear in the Auto List Members list.

REFERENCES

For more information about using the ActiveControl object, search the Help Index for "ActiveControl property," or ask the Microsoft Access 97 Office Assistant.


Additional query words: screen
Keywords : PgmObj
Version : WINDOWS:97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.