ACC: No Err w/ Multiple Dynaset.Close Statements Based on FormID: Q93292
|
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.
This behavior is by design.
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.
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
Keywords : kbprg PgmObj
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: March 12, 1999