PRB: Dynaset, Snapshot, and Table Objects No Longer Available
ID: Q129883
|
The information in this article applies to:
-
Microsoft Visual Basic Professional and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0
SYMPTOMS
If you try to dimension a Dynaset, Snapshot, or Table object variable and
using DAO 3.0 (Visual Basic version 4.0 data access objects), you will
receive this runtime error:
User-defined type not defined.
If you replace the Dynaset, Snapshot, or Table object with the Object or
RecordSet type and use methods such as CreateDynaset, CreateSnapshot, or
OpenTable that are tied to the Dynaset, Snapshot, or Table types, you will
receive this error:
Feature not available.
CAUSE
Visual Basic version 4.0 has replaced the older Dynaset, Snapshot, and
Table objects with a single RecordSet object. This object can take on the
attributes of any of the older three making it much more powerful and
flexible.
RESOLUTION
You can resolve this problem one of two ways.
- Replace references to the older objects, while retaining lines of code
such as these:
Dim DB As Database
Set DB = OpenDatabase("Biblio.mdb")
For example, instead of this old code:
Dim DS As Dynaset
Dim SS As Snapshot
Dim TB As Table
Set DB = OpenDatabase("Biblio.mdb")
Set DS = DB.CreateDynaset("Authors")
Set SS = DB.CreateSnapshot("Authors")
Set TB = DB.OpenTable("Authors")
Use this new code:
Dim DB As Database
Dim RS1 As Recordset
Dim RS2 As Recordset
Dim RS3 As Recordset
Set DB = OpenDatabase("Biblio.mdb")
Set RS1 = DB.OpenRecordset("Authors", dbOpenDynaset)
Set RS2 = DB.OpenRecordset("Authors", dbOpenSnapshot)
Set RS3 = DB.OpenRecordset("Authors", dbOpenTable)
-or-
- Retain the older syntax and change the Data Access Object (DAO) Type
Library that your program uses. Although Microsoft recommends the first
method for future compatibility, using the older syntax is useful for
compiling code written in previous versions of Visual Basic in version
4.0 with a minimal number of changes. To change the DAO Type Library:
- Choose References from the Tools menu in Visual Basic.
- Clear the Microsoft DAO 3.0 Object Library selection.
- Select the Microsoft DAO 2.5/3.0 Compatibility Library.
STATUS
This behavior is by design.
MORE INFORMATIONSteps to Reproduce Behavior
With the Microsoft DAO 3.0 Object Library selected in Tools REFERENCES
- Start a new project in Visual Basic. Form1 is created by default.
- Add a Data Control (Data1) to Form1.
- Add the following code to the Form1_Click procedure:
Sub Form1_Click()
Dim ds As dynaset 'this generates "User-defined type not defined"
Data1.Databasename = "Biblio.MDB"
Data1.RecordSource = "Authors"
Data1.Refresh
Set ds = Data1.Recordset.CreateDynaset()
' If ds is Dim'd as a RecordSet,
' this generates "Feature not available"
ds.Close
Set ds = Nothing
End Sub
- Start the program by choosing Start from the Run menu or by pressing the
F5 key. The 3251 error will be generated on the CreateDynaset line.
Additional query words:
4.00 vb4win vb4all
Keywords :
Version : 4.00
Platform : WINDOWS
Issue type :
|