ACC: No Err w/ Multiple Dynaset.Close Statements Based on Form
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
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 "? 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 : kbprg PgmObj
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbprb