Cursor, Relation
These two classes are members of the Data environment. Cursor represents an individual table or view (but we'll say only "table" below unless something is relevant only to views) that's been added to the DE. Relation contains information about a relation between two cursors in the DE.Each time you add a table to the Data environment, a new Cursor object is added. It points to the table and lets you set properties (like Alias and Order) used when the table is opened by the DE, either automatically because AutoOpenTables is .T. or by explicitly calling OpenTables.When you add a table to the DE and that table has a persistent relation with a table already in the DE, a Relation is added. (If the new table has persistent relations with multiple tables, multiple relation objects are added.) The new relations reflect the structure of the persistent relation—in a one-to-many persistent relation, the "one" side becomes the parent and the "many" side becomes the child. Order is automatically set appropriately in the child (via the Relation's ChildOrder property, not the Cursor's Order property). However, the OneToMany property of the relation is never set to .T. automatically—you have to do that yourself. We originally had mixed feelings about this one. After all, we've already told FoxPro it's a one-to-many relationship. However, we rarely end up setting OneToMany ourselves—it just doesn't seem that important. Besides, with a grid for the "many" side, you can see all the children for the current parent anyway.You can also add relations by "drawing" them in the Data environment Designer. Drag from a field of one table to a field or index of another. (If there's no index for the field you specify on the child side, you're prompted to let Visual FoxPro create it for you.) Notice that the technique for setting up relations in the DE is different than in the Database Designer. That's because the relations here are temporary relations (the SET RELATION TO kind), not persistent relations.Cursor
Property |
Value |
Purpose |
Character |
The alias to use for this table or view in the form. |
|
Numeric |
Indicates the type of buffering to use for this cursor. |
|
Character |
The name of the table or view the cursor is based on. For free tables, includes the full path. |
|
Character |
The name of the database containing this table or view. |
|
Logical |
Indicates whether or not to open the table exclusively. |
|
Character |
The filter expression to apply to the cursor. |
|
Logical |
View only. Indicates whether the data for the view is loaded initially or waits until REQUERY() is executed. |
|
Character |
The name of a tag to apply to the cursor. |
|
Logical |
Determines whether the table or view is opened in read-only mode. |
Relation
Property |
Value |
Purpose |
Character |
The alias for the child cursor (the INTO part of SET RELATION). |
|
Character |
The tag used to order the child so the relation can be applied. Should correspond to RelationalExpr. |
|
Logical |
Determines whether a one-to-many relation is established. |
|
Character |
The alias for the parent cursor. |
|
Character |
The expression to use to set the relation. Equivalent to the "TO" clause of SET RELATION. |
Example |
* You'll normally set this stuff only in the Properties Sheet * In fact, most of it happens automatically. Here are some * items you might actually set. * Assume the PropSheet is pointing at a cursor for Employee. Filter = "NOT EMPTY(Sales_Region)" Order = "Last_Name" * At runtime, you might: ThisForm.DataEnvironment.Cursor1.Order = "Name" |