RecordSource, RecordSourceType
These two properties determine what table or cursor provides the data for a grid. RecordSourceType, which tells the grid what kind of object to get its value from, offers the expected choices plus one really strange one. RecordSource identifies the particular item that provides the grid data.
Usage |
grdGrid.RecordSource = cSource cSource = grdGrid.RecordSource grdGrid.RecordSourceType = nSourceType nSourceType = grdGrid.RecordSourceType |
With RecordSourceType set to 2-Prompt, if no table is open in the current work area you're prompted to choose one, but if the table you choose is already open in another work area, the grid doesn't get filled at all—it consists of just a thin black outline. We can't think of any situation in which that's the desired result. |
If you do something that closes the RecordSource of a grid (like rerun the query that created it), the grid clears out. All you have is a rectangle in the grid's BackColor. If you re-create the cursor or reopen the table, you have to reset RecordSource to the cursor (or SQL statement) to refill the grid, but any column-level changes you've made (like header captions or column widths or ColumnCount) are lost for good. This is another case where a view is a better choice. |
Example |
This.RecordSourceType = 0 && Table This.RecordSource = "Employee.DBF" |
See Also |