Microsoft KB Archive/93292

= ACC: No Error with Multiple Dynaset.Close Statements Based on a Form =

Article ID: 93292

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q93292



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



SYMPTOMS
If you use code to create a recordset that is based on a form, you can use 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
 Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0). Open the Customers form in Form view.  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  On the View menu, click Debug Window (or Immediate Window in versions 1.x and 2.0). Run the code that you created in step 3 by typing &quot;? MultiClose&quot; (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.</li></ol>

Keywords: kbprb kbprogramming KB93292

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.