APPLICATION DESIGN


Using subforms
A subform is a collection of form elements that are stored as a single object. Subforms can contain the same elements as regular forms. Subforms save redesign time. When you change a field on a subform, every form that uses the subform updates. Common uses of subforms include adding a company logo to business documents or adding mailing label information to mail and memo forms. A subform can be a permanent part of a form or can appear conditionally, depending on the result of a formula. For example, you might offer users a choice of custom mail forms with different graphics and styles for various types of mail messages, such as memos, alerts, or letters. Note that field names used in the subform can't be used elsewhere on the form. Changes you make to a subform affect all forms and documents that use the subform.

To create a subform

You can copy and modify a subform that is similar to the one you need or create a new subform and design it yourself.

1. Open the database that will have the new subform and click Shared Code - Subforms.

2. Click "New Subform."

3. Create the subform using the same elements you use to create a form.

4. Choose Design - Subform Properties. The Subform Properties box appears.

5. At the Subform Info tab, enter a name for the new subform.

6. Optionally, you can enter a comment.

7. Choose from the following options for displaying the subform:
Subform propertyUse
Include in Insert Subform dialogLets designers see the subform name when inserting a subform. Excluding a subform from the Insert Subform dialog box is not a security measure. Users with Designer access or higher can open any subform in IBM® Lotus® Domino(TM) Designer and copy individual components. Note that this field does not apply to computed subforms.
Include in New Form dialogCheck this if you want the subform to appear immediately when designers choose Create - Design - Form. Note that this field does not apply to computed subforms.
Render pass through HTML in NotesLets you paste HTML directly into the subform. For more information on pasting in HTML, see the topic "Using HTML on a page or form" in the "Designing Pages" chapter.
Do not add field names to field indexCheck this setting to prevent new field names on the subform from being saved in the field index. Checking this setting saves memory.

If you do not check this setting, field names are saved to a table and then stored in memory. Storing field names in memory allows field names to appear in places such as the "Add Action" dialog box.

8. Close and save the subform.

To insert a subform on a form

1. Open a form.

2. Place the cursor where you want to paste the subform.

3. Choose Create - Resource - Insert Subform. The Insert Subform dialog box appears.

4. Select the subform you want and click OK. You can also insert subforms contained in other databases by selecting a database listed in the Database pull-down list.

To display a computed subform on a form

1. Open a form.

2. Place the cursor where you want to paste the subform.

3. Choose Create - Resource - Insert Subform.

4. Select "Insert Subform based on formula."

5. Click OK.

6. Enter a formula in the Programmer's pane that determines which subform to display.

7. Close, name, and save the form.

Example of displaying a computed subform

In the Main Topic form of a discussion database, you want to display the NewDocSubform when a document is created and the SavedDocSubform when a saved document is opened. Each subform contains different fields and graphics. The Insert Subform formula is:

@If(@IsNewDoc;"NewDocSubform";"SavedDocSubform");

Note Subform formulas cannot be refreshed while the document is open.

Deleting subforms

When a user opens a document that references a deleted subform, the message "Subform: <subform name> not loaded" appears on the status bar. The document opens without any representation of the deleted subform. When a designer opens a form that references a deleted subform, the message "Subform: <subform name> not loaded" appears on the status bar. When a designer clicks the deleted subform area on the form, the message "Invalid or nonexistent document" appears and the designer can't open the subform.

To avoid these messages, add another subform to the database and give it the same name as the deleted one.

To delete a subform from a form

You can remove a subform from an individual form, without disturbing other forms that use it.

1. Click the subform area on a form.

2. Choose Edit - Delete.

3. Adjust the formatting if necessary.

To delete a subform from a database

You can remove all instances of a subform from a database. Be aware that this will cause errors in any form that refers to the subform.

1. Click Subforms in the design list for the database.

2. Choose Edit - Delete.