PRB: CreateDynaset Err: Can't open any more tables or queries
ID: Q113388
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions 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:
- Start a new project in Visual Basic. Form1 is created by default.
- Add a command button (Command1) and a text box (Text1) to the form.
- 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
- 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
- Start a new project in Visual Basic. Form1 is created by default.
- Add a command button (Command1) and a text box (Text1) to the form.
- 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
- Run the code. The error should occur on the tenth iteration.
Additional query words:
3.00
Keywords :
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type :