PRB: CreateDynaset Err: Can't open any more tables or queries

Last reviewed: June 21, 1995
Article ID: Q113388
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, version 3.0

SYMPTOMS

After using the CreateDynaset method several times to create a dynaset from the dynaset itself, you will receive this error:

   Can't open any more tables or queries.

Most often, you would be using the Sort or Filter property in this process. However, it is not necessary to do this to re-create the problem.

CAUSE

The number of times a dynaset can be created from itself is limited in the current design of Visual Basic.

WORKAROUND

To work around the problem, base all sorts or filters off of a different dynaset. The following example illustrates this:

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add a command button (Command1) and a text box (Text1) to the form.

  3. Add the following code in the command click event.

       Sub Command1_Click()
          Dim db As Database
          Dim ds As Dynaset
          Dim ds2 As Dynaset
          Set db = OpenDatabase("C:\VB\BIBLIO.MDB")
          Set ds = db.CreateDynaset("SELECT * FROM Authors")
          Set ds2 = ds
          Do
             iCount = iCount + 1
             Text1.Text = iCount
             ds2.Sort = "Author"
             Set ds = ds2.CreateDynaset()
          Loop
       End Sub
    
    

  4. Run the program or press the F5 key.

The problem does not occur with snapshot objects.

STATUS

This behavior is by design in Visual Basic version 3.0 for Windows. However, Microsoft is considering a change for future releases.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add a command button (Command1) and a text box (Text1) to the form.

  3. Add the following code in the Command1 click event:

       Sub Command1_Click()
          Dim db As Database
          Dim ds As Dynaset
          Set db = OpenDatabase("C:\VB\BIBLIO.MDB")
          Set ds = db.CreateDynaset("SELECT * FROM Authors")
          Do
             iCount = iCount + 1
             Text1.Text = iCount
             Set ds = ds.CreateDynaset()
          Loop
       End Sub
    
    

  4. Run the code. The error should occur on the tenth iteration.


Additional reference words: 3.00
KBCategory: kbprg kbcode kbprb
KBSubcategory: PrgOptMemMgt


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.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.