Bound Mode > Visual Basic Data Control Considerations > Using True DBGrid with a Data control on a different form |
Using the Data control's Recordset property, you can effectively bind True DBGrid or any other bound control on one form to a Data control on another form. Strictly speaking, you cannot directly bind a grid to a Data control on another form. For example, assume you have a grid on Form2 and you would like it to display data from the Recordset of Data1, which is on Form1. You need to first bind the grid to a Data control (Data2) on Form2. Form2.Data2 is not connected to a database. Instead, the Recordset of Form2.Data2 is set to the Recordset of Form1.Data1:
Example Title |
Copy Code
|
---|---|
Form2.Data2.DatabaseName = Form1.Data1.DatabaseName Set Form2.Data2.Recordset = Form1.Data1.Recordset |
The grid on Form2 will work as if it were directly bound to Form1.Data1. When you move or update records through Form1.Data1, the grid on Form2 will respond accordingly. Conversely, if you move or update records in the grid, all controls on Form1 that are bound to Form1.Data1 will respond.