DAO: How to Assign a Recordset to a Data Control in VB 4.0Last reviewed: July 25, 1996Article ID: Q147882 |
The information in this article applies to:
SUMMARYSome improvements have been made to the data control in Microsoft Visual Basic version 4.0 for Windows. One of these improvements is the capability to assign back the results of a Recordset object to the data control itself. This was not possible in Microsoft Visual Basic version 3.0 for Windows. This article demonstrates how to assign a Table-type, Dynaset-type, or Snapshot-type Recordset object back to a data control's Recordset property.
MORE INFORMATIONThe OpenRecordset method has three possible types of records that it can produce. Below is a portion of the Visual Basic Online Help that describes the Openrecordset method that mentions these three types:
dbOpenTable to open a table-type Recordset object. dbOpenDynaset to open a dynaset-type Recordset object. dbOpenSnapshot to open a snapshot-type Recordset object.Also, the following was taken directly from Chapter 4 of the "Guide to Data Access Objects" book contained in the "Professional Features" Visual Basic manual:
When you open a database using the data control, a Recordset object is automatically created based on the control's RecordSource property. You can address this Recordset with the following syntax: Data1.RecordsetAll of the Recordset properties and methods discussed in this chapter can be used with the data control's Recordset. In addition, you can assign the data control's Recordset object to any Recordset variable you create. For example:
Dim MyRecordset As Recordset Set MyRecordset = Data1.RecordsetConversely, you can assign a Recordset object that you create programmatically or with a data control to another data control, using the following syntax:
Set Data1.Recordset = MyRecordsetWhen you assign a new Recordset object to the data control's Recordset property, you must use the data control's Refresh method to rebuild the Recordset and allow the data control to properly display it. In addition, you must make sure that the DataField property of all bound controls attached to the data control reflect valid fields in the new Recordset.
Step-by-Step Example
|
Additional reference words: 4.00 vb4win vb432
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |