Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

LinkMaster

LinkMaster lets you specify the parent table that should drive the contents of a grid. You’ll normally use it together with ChildOrder and RelationalExpr.

Usage

grdGrid.LinkMaster = cParentAlias
cParentAlias = grdGrid.LinkMaster

The folks who designed Visual FoxPro think you’ll most often use a grid as the “many” side of a one-to-many relationship. They’re probably right.

As a result, grids have a bunch of properties aimed at making it easy to set up that situation. Most of these properties are shared with the data environment’s Relation object. LinkMaster isn’t one of those—it belongs only to grids.

There are actually two ways to set up a one-to-many grid. You can do it either by establishing the correct relation in the data environment or by setting the grid’s properties directly. If you specify a one-to-many relationship between two cursors in the data environment and then put the child (many) table in a grid, you’ll always see only the child records that relate to the current parent (one) record (even if no fields from the parent appear in the form).

The alternative approach is to specify everything at the grid level. When you do that, LinkMaster contains the alias for the parent table. Set ChildOrder and RelationalExpr to complete the relationship.

Although LinkMaster can be changed at runtime, we haven’t been able to actually make changing it do anything useful. Generally, you’ll need to change ChildOrder as well, and that’s tricky when you’re working in a grid.

Example

* You'll normally set this one in the Property Sheet, but the
* code would look like:
This.LinkMaster = "OrdItems"

See Also

ChildOrder, RecordSource, Relation, RelationalExpr