|
|
Title | Use a bound DBGrid control |
Keywords | DBGrid, bound DBGrid |
Categories | Controls, Database |
|
|
Place a DBGrid and Data control on the form. Set the DBGrid's DataSource property to the Data control. Set other properties such as AllowAddNew, AllowDelete, and AllowUpdate as desired.
Set the Data control's DatabaseName property to the database. This example sets the database name at runtime like this:
|
|
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\CoData.mdb"
End Sub
|
|
Set the Data control's RecordSource property to the SQL SELECT statement the control should use to pick the data to be displayed. In this example, the property is set to:
SELECT Name, Department, Manager
FROM Employees, Departments
WHERE Employees.Department = Departments.DepartmentName
The DBGrid control displays the data automatically.
|
|
|
|
|
|