How to Set Up Related Forms

Our objective in designing the Related Forms engine for VPM Enterprise was to make setting up Related Forms as simple as possible. It occurred to us that it would be simplest if you didn't have to do anything at all to set up Related Forms, and we think we have met that objective in VPM Enterprise.

Related Forms Design Objective: Don't require the developer to do anything at all to set up Related Forms.

How do we accomplish this objective? It's simple really (at least it's simple in concept, it wasn't simple to implement). When you set up Referential Integrity, or Referential Validation, in the Data Builder for your tables, views and CursorAdapters, you are at the same time telling VPM Enterprise how your tables, views and CursorAdapters are related. Since Related Forms display data from related tables, views and CursorAdapters, you are also at the same time telling VPM Enterprise how your forms should be related. Since you need to set up Referential Integrity among your tables, views and CursorAdapters anyway, you don't have to do anything in addition to set up Related Forms.

It's all done in the Data Builder. You don't have to do anything when you design a form.

ō To set up Related Forms in VPM Enterprise

Set up Referential Validation in the Data Builder (see Referential Validation) for the child table foreign key(s) that link to the parent table primary key(s). That's it. However, here are some things to be sure to do:

∑       Form Name Property: Make sure the form Name property is unique for each form in the Related Forms group.

Tip: You should make the Name property of every form in an application unique.

∑       Primary Keys: The parent table, view or CursorAdapter, each child table, each grandchild table, etc. must have a Primary Key tag selected on a Tagís Edit page in the Data Builder.

∑       Foreign Key Tags: In the Data Builder, create an index tag for the field(s) that link a child, grandchild, etc. table, view or CursorAdapter to its parent table, view or CursorAdapter.

Important: The foreign key tag expression must not contain any other fields but the foreign key fields.

∑       Referential Validation - FK Tag: In the Data Builder, you must set up Referential Validation for the foreign key field(s) that link a child, grandchild, etc. to its parent table, view or CursorAdapter. Be sure to select the FK Tag (Foreign Key Tag) (that you created in the previous step) in the FK Tag combo box on the Integrity page.

Tip - How to Turn Off Related Forms for a Table, View or CursorAdapter: If you donít want the forms you create for a table, view or CursorAdapter to be processed by the VPM Enterprise Related Forms engine, set the FK Tag combo box to ďNoneĒ on the Integrity page in the Data Builder. This will also turn off One-to-Many and Related Pages form functionality for the child, grandchild, etc.

∑       Child Table, View and CursorAdapter Indexes: The indexes that you want displayed on the Toolbar Order dialog for a Related Forms child table, view or CursorAdapter must begin with the foreign key field(s) in the child table, view or CursorAdapter that links the child table, view or CursorAdapter to the primary key field(s) in the parent table, view or CursorAdapter. Be sure that the child table, view or CursorAdapter indexes that you want to display in the Toolbar Order dialog are set up this way. See Index Tags and Toolbar Order Control for more information on this subject.

Thatís it! Thatís all you have to do to set up your parent, child, grandchild, etc. forms for the VPM Enterprise Related Forms engine.

If you successfully complete the five steps described above, the next time you run a parent form and then run a child form, the child form records will be positioned to the records that match the current parent form record.

How to Turn Off Related Forms for a Form

 The lRFDisable property of the Form_Toolbar class controls whether a form is processed by the VPM Enterprise Related Forms engine. By default, itís set to .F. If you set this property to .T., the VPME Related Forms engine will not run when the form is activated. In other words, if you set this property to .T., the form will never be a Related Form unless you change this property in code.

The lRFDisable property is evaluated in a formís Activate event, and therefore, any code you want to run to control the property should be inserted to run prior to the code in the Activate event that evaluates this property. If you wanted your code to only be run when a form is first activated, you would put your code in the Load or Init event. If you wanted your code to be run whenever the form is activated, you would put your code in the formís Activate event prior to a DODEFAULT() line that runs the parent class code.

More:

Related Forms - Things You Should Know