PRB: InSelection Property Example Returns Incorrect Value

    Article ID: Q138773
    Creation Date: 26-OCT-1995
    Revision Date: 19-SEP-1996

    The information in this article applies to:

    • Microsoft Access version 7.0

    SYMPTOMS

    Moderate: Requires basic macro, coding, and interoperability skills

    The sample function, IsControlSelected() in the InSelection Property Example in online Help returns 0 (False) even if the control you are looking for is selected.

    CAUSE

    The For...Next loop in the IsControlSelected() function continues to run even after the desired control is found. The IsControlSelected() function actually returns the last control checked on the form. This code would only return -1 (True) if the control searched for is the last one on the form.

    RESOLUTION

    In the IsControlSelected() function, right after the line

       IsControlSelected = True
    
    
    add the following line:

       Exit Function
    
    
    REFERENCES

    For more information about InSelection, search for "InSelection," and then "InSelection Property" using the Microsoft Access for Windows 95 Help Index.

    For more information about For...Next loops, search for "For Statement," and then "For...Next Statement" using the Microsoft Access for Windows 95 Help Index.


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.
©1997 Microsoft Corporation. All rights reserved. Legal Notices.

Additional reference words: 7.00
KBCategory: kbusage kddocerr
KBSubcategory: DcmHlp