Data Control

See AlsovbobjQueryControlSee              PropertiesvbobjQueryControlProp           EventsvbobjQueryControlEvt           MethodsvbobjQueryControlMth


A data control provides access to data stored in databases, and allows you to move from record to record and display data from each record in bound controlsLVLJ7W.  Without a data control, you cannot have bound controls on a form.


You can perform most data access operations without writing any code at all.  Controls bound to a data control automatically display data from a specific field for the current record1BNJB8X.  If the data control moves to a different record, all bound controls automatically change to display the current record.  If a user changes data or enters new information through a control bound to the data control, the changes are automatically saved in the database when the data control moves to a new record.  You can use the Validate event and the DataChanged property to fine-tune your application.

To open a Database with a data control, set the DatabaseName property with the path and name of the data source name, then set the RecordSource property to the name of a Table or QueryDef in the Database.  You can also use an SQL statement29F05E5 in the RecordSource property to specify a recordset.  You can bind controls to a data control only at design time with the DataSource property.

A data control has two properties that are really data access objects: Database and Recordset.  These properties are references to a data control's underlying Database object and Dynaset object.  Database objects and Dynaset objects each have properties and methods of their own, and you can use a data control with these properties and methods to manipulate your data.  For example, the MoveNext method of a Dynaset moves the current record to the next record in the recordset.  To invoke this method, you could use this code: