ACC: No Err w/ Multiple Dynaset.Close Statements Based on Form

Last reviewed: August 6, 1997
Article ID: Q93292
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

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

If you use code to create a recordset that is based on a form, you can have multiple dynaset.Close statements without generating an error message.

STATUS

This behavior is by design.

MORE INFORMATION

NOTE: The Dynaset property is included in Microsoft Access 2.0, 7.0 and 97 only for compatibility with earlier versions. It is recommended that you use the RecordsetClone property instead. In Microsoft Access 7.0 and 97, there is no Dynaset Object; therefore, you cannot declare a variable as a Dynaset.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).

  2. Open the Customers form in Form view.

  3. Create the following new module.

        In Microsoft Access 7.0 and 97
        ------------------------------
    

          Function MultiClose()
    
             Dim MyDyna as Recordset
             Set MyDyna=Forms![Customers].Dynaset
             MyDyna.Close
             MyDyna.Close
          End Function
    
        In Microsoft Access versions 1.x and 2.0
        ----------------------------------------
    
          '*******************************************************
          'Declarations section of the module.
          '*******************************************************
    
          Option Explicit
    
          '=======================================================
          ' The following function will create a dynaset based on
          ' the Add Products form in the Northwind database. The
          ' function will then attempt to close the dynaset twice.
          '=======================================================
    
          Function MultiClose()
             Dim MyDyna as Dynaset
             Set MyDyna=Forms![Customers].Dynaset
             MyDyna.Close
             MyDyna.Close
          End Function
    
    

  4. On the View menu, click Debug Window (or Immediate Window in versions 1.x and 2.0).

  5. Run the code you created in step 3 by typing "? MultiClose()" (without the quotation marks) in the Debug Window. Note that there are no error messages, even though the code attempts to close the dynaset more than once.
Keywords          : PgmObj JetRS kbprg
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbprb
Solution Type     : Info_Provided


================================================================================


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: August 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.