One other nice method available for the
object is Recordset
. So far, we've only talked about a NextRecordset
property as containing one SQL query. We can provide multiple SQL queries as long as they are separated by semicolons, in the form CommandText
SELECT
*
FROM
Table1;
SELECT
*
FROM
etc.. Normally, when we open a recordset from a query like this, it's only the first set of results that are available. To retrieve the next set of records we just call the Table2;
method. We can also supply the name of a variable that will be set to the number of records affected by the query, though this is optional:NextRecordset
recordset Set
recordset=
RecordsAffected.NextRecordset(
)
When we use the
method, we're provided with a new NextRecordset
variable that is one of the following:Recordset
Recordset
object referenced by the variable will be empty. We can test for this case by inspecting the BOF
and EOF
properties, which will both be True
.Recordset
referenced by the variable will be closed. We can test for this case by ensuring that the Recordset
object variable is not equal to Nothing
. In this case, inspecting the EOF
property will generate an error.Recordset
variable returned will be set to Nothing
.
Note that the
method will continue to return NextRecordset
objects as long as there are additional SQL statements in our Recordset
parameter.CommandText