Understanding Subform Reuse

Subforms can exist as discrete objects in the system. You can place the subform itself on a power form; this action is referred to as embedding. You can also reference an existing subform on a power form with an alias; this action is referred to as reusing. Typically, developers reuse subforms that are designed to appear on numerous forms, such as the display of address book information. In this way, you can more easily standardize the interface.

A reused subform is actually just a pointer; therefore, it is unaware of its parent and children in any given context. If you want a reused subform to communicate with its parent or children, you must do so through ER. While you cannot embed a subform within another subform, you can reuse a subform within another subform. In other words, you can embed or reuse a subform within a reusable subform, but you cannot embed or reuse a subform within an embedded subform.

Inserting reusable subforms in a form is different from inserting an embedded subform. They exist as two different control types in the user interface. Therefore, the FDA Menu/Toolbars contain two different insert actions. If you insert an alias, you are prompted for the application. If you insert a reusable subform, you are prompted for the subform. You cannot insert a subform onto a form until the application the subform has been defined in has been saved.

To make reusing subforms effective, you must plan carefully and be cautious when altering subforms. For example, if both a parent and a child are reused, then you must set up their data mappings in a way that facilitates their passing information to each other. You should use variables as often as possible, especially for business view columns (BCs), grid columns (GCs), and form controls (FCs). Establish a naming convention for the variables so that you can determine which ones were created for the purpose of mapping. That way, if another developer wants to reuse the subform and sees several "extra" variables, that developer will understand that the variables are not extraneous.

Knowing that any subform can be reused, you must be careful when changing a subform, even just resizing it. Anyone who is currently pointing to the subform will see the changes you make. It is possible that if you make the subform a little larger that it will no longer fit on someone else's form. Even worse, if you change the data structure by removing elements from it, you might break someone else's application.

Note: Always determine the full effect of changing a subform, especially its data structure. If you reuse subforms in the applications, check them occasionally to ensure that the subforms have not been altered in such a way as to negatively affect the applications.