Microsoft KB Archive/106270: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 92: | Line 92: | ||
<pre class="codesample"> Dim db As database | <pre class="codesample"> Dim db As database | ||
Dim recordset As table ' Correction: Dim recordset As dynaset | Dim recordset As table ' Correction: Dim recordset As dynaset | ||
Set db = OpenDatabase( | Set db = OpenDatabase("c:\vb3\biblio.mdb") | ||
Set recordset = db.OpenTable( | Set recordset = db.OpenTable("authors") ' Instead: db.CreateDynaset | ||
' The following line gives | ' The following line gives "can't perform operation; it is illegal": | ||
recordset.FindFirst | recordset.FindFirst "Author like 'a*'" | ||
Debug.Print recordset.Fields( | Debug.Print recordset.Fields("Author") | ||
</pre> | </pre> | ||
The following code works around this behavior by first creating a Dynaset from the Table, and then using FindFirst on the Dynaset: | The following code works around this behavior by first creating a Dynaset from the Table, and then using FindFirst on the Dynaset: | ||
Line 102: | Line 102: | ||
' Dim recordset As table ' Gives problem. | ' Dim recordset As table ' Gives problem. | ||
Dim recordset As dynaset ' Workaround. | Dim recordset As dynaset ' Workaround. | ||
Set db = OpenDatabase( | Set db = OpenDatabase("c:\vb3\biblio.mdb") | ||
' Set recordset = db.OpenTable( | ' Set recordset = db.OpenTable("authors") ' Gives problem. | ||
Set recordset = db.CreateDynaset( | Set recordset = db.CreateDynaset("Authors") ' Workaround. | ||
recordset.FindFirst | recordset.FindFirst "Author like 'a*'" | ||
Debug.Print recordset.Fields( | Debug.Print recordset.Fields("Author") | ||
</pre> | </pre> | ||
Line 114: | Line 114: | ||
== REFERENCES == | == REFERENCES == | ||
See | See "Positioning the Current Record in a Recordset" on Pages 68-77 of the Visual Basic Professional Edition, version 3.0, "Professional Features Book 2" manual. Page 72 states, "The Find methods cannot be used on Table objects." | ||
</div> | </div> |
Latest revision as of 10:09, 20 July 2020
Article ID: 106270
Article Last Modified on 1/8/2003
APPLIES TO
- Microsoft Visual Basic 3.0 Professional Edition
This article was previously published under Q106270
SYMPTOMS
Using the FindFirst, FindNext, FindLast, or FindPrevious method on an object variable of type Table results in this error:
Pressing the F1 key on this error dialog gives the following description from the Visual Basic Help:
CAUSE
The FindFirst, FindNext, FindLast, and FindPrevious methods can be used only with a Dynaset or Snapshot. These Find methods cannot be used with a Table object variable.
WORKAROUND
To move between the records of a Table, use the Seek method or the Move methods (MoveFirst, MoveLast, MoveNext, and MovePrevious).
Also, you can create a Dynaset or Snapshot variable on the whole Table by using the CreateDynaset or CreateSnapshot method. Then you can use the FindFirst, FindNext, FindLast, and FindPrevious methods on that Dynaset or Snapshot. The Find methods move between records that meet specific conditions.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
The following code demonstrates the error using the FindFirst method on a Table object variable:
Dim db As database Dim recordset As table ' Correction: Dim recordset As dynaset Set db = OpenDatabase("c:\vb3\biblio.mdb") Set recordset = db.OpenTable("authors") ' Instead: db.CreateDynaset ' The following line gives "can't perform operation; it is illegal": recordset.FindFirst "Author like 'a*'" Debug.Print recordset.Fields("Author")
The following code works around this behavior by first creating a Dynaset from the Table, and then using FindFirst on the Dynaset:
Dim db As database ' Dim recordset As table ' Gives problem. Dim recordset As dynaset ' Workaround. Set db = OpenDatabase("c:\vb3\biblio.mdb") ' Set recordset = db.OpenTable("authors") ' Gives problem. Set recordset = db.CreateDynaset("Authors") ' Workaround. recordset.FindFirst "Author like 'a*'" Debug.Print recordset.Fields("Author")
REFERENCES
See "Positioning the Current Record in a Recordset" on Pages 68-77 of the Visual Basic Professional Edition, version 3.0, "Professional Features Book 2" manual. Page 72 states, "The Find methods cannot be used on Table objects."
Additional query words: 3.00
Keywords: kbprb KB106270