Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a bound DBGrid control
KeywordsDBGrid, bound DBGrid
CategoriesControls, 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.

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated