DataControl
From Real Software Documentation
Allows the user to browse among records in a database table by clicking buttons. It consists of First Record, Previous Record, Next Record, and Last Record navigation buttons and a label that displays the Caption property. Built-in events fire when the user clicks any button. Methods allow you to navigate among rows programmatically.
Notes
A DataControl is designed to display data using Checkboxes, TextFields and TextAreas, ListBoxes, Labels PopupMenus, and ComboBoxes. You can also create custom classes that are based on any of these classes and use them in conjunction with a DataControl.
Each of these controls (or their subclasses) has two properties that are specific to the DataControl: DataSource and DataField. DataSource accepts a DataControl object and DataField accepts the name of a field in the table to which the DataControl is linked. You set up a database interface by linking a DataControl to a table in a database and then linking each field whose values you wish to display to a Checkbox, TextField or TextArea, ListBox, Label, PopupMenu or ComboBox using the DataField and DataSource properties.
| Properties | ||||||||||||||||||||||||||||||||||||
|
| Methods | ||||||||||||||||||||||||
|
Notes
When you add a DataControl to a window, it looks like these three examples.
You use a DataControl by creating a window that uses Checkboxes, TextFields or TextAreas, ListBoxes, PopupMenus, ComboBoxes, or Label controls to display and edit data. Each of these controls has two properties that are meaningful only when used in conjunction with a DataControl, DataField and DataSource.
When you build an interface using a DataControl, it makes it easy to modify and save records. When the user saves changes, it automatically updates the values in the database back end with the values in the controls bound to the DataControl. If you need to update other values, you need to do it conventionally using the RecordSet method of the DataControl.
Examples
The following example database displays fields in TextFields ane uses a DataControl for record navigation.
The DataControl's properties in the Behavior group in its Properties pane specify that it will manage the records in the Movies table in the database.
The SQLQuery property is the SQL query that will run when the form is opened. This query finds all the records in the Movies table. This means that the DataControl's navigation buttons can be used to browse through all the records right after the form opens.
Each TextField is linked to the DataControl in its Properties pane by setting the DataSource and DataField properties. When you set the DataSource, a pop-up menu of fields from the table specified by the database becomes available for the DataField property. For example, the TextField for the movie title is bound to the column "Title" in the table to which the DataControl is linked.
Each field on the form is bound to a field in the Movies table in this manner.
To add a new record, click the Add button and enter the information into the fields. To modify a record, navigate to it using the buttons on the DataControl, edit the values, and click Update. To delete a record, navigate to it using the buttons in the DataControl and click Delete.
See Also
Database, DatabaseField, DatabaseRecord, RecordSet classes.



