DOCUMENT:Q129883 02-FEB-2002 [vbwin] TITLE :PRB: Dynaset, Snapshot, and Table Objects No Longer Available PRODUCT :Microsoft Visual Basic for Windows PROD/VER:4.00 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Professional Edition, 16-bit, for Windows, version 4.0 - Microsoft Visual Basic Professional Edition, 32-bit, for Windows, version 4.0 - Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows, version 4.0 - Microsoft Visual Basic Enterprise Edition, 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: 1. Choose References from the Tools menu in Visual Basic. 2. Clear the Microsoft DAO 3.0 Object Library selection. 3. Select the Microsoft DAO 2.5/3.0 Compatibility Library. STATUS ====== This behavior is by design. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- With the Microsoft DAO 3.0 Object Library selected in Tools REFERENCES ---------------------------------------------------------------------- 1. Start a new project in Visual Basic. Form1 is created by default. 2. Add a Data Control (Data1) to Form1. 3. 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 4. 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 : Technology : kbVBSearch kbAudDeveloper kbVB400Search kbVB400 kbVB16bitSearch Version : 4.00 Issue type : kbprb ============================================================================= 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. Copyright Microsoft Corporation 2002.