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. In an open database, double-click Shared Elements - Subforms in the Applications Navigator, and then click New Subform. Alternatively you can choose File - New - Subform.
  2. In the New Subform dialog box, assign a name, select the application if necessary, and click OK.
  3. Design the subform. Create fields, text, and other elements on the subform.
  4. Choose Design - Subform Properties. The Subform Properties box appears.
  5. Optionally, you can enter a comment.
  6. Choose from the following options for displaying the subform:

    Subform property

    Use

    Include in Insert Subform dialog

    Lets 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 Domino® Designer and copy individual components. Note that this field does not apply to computed subforms.

    Include in New Form dialog

    Check 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 Notes®

    Lets 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 index

    Check 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.

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 Shared Elements - Subforms in the design list for the database.
  2. Choose Edit - Delete.

Subforms, XPages, and data binding

When using a subform on an XPage, you may find that you cannot "data bind" to fields in a subform that is included on that XPage.

For example, say you create a new application using the Discussion Template and then create a new XPage. When you try to create a new data source to the 'Response' form, and drag and drop an Edit Box to the page and attempt to "data bind" this to the 'Subject' field , the field is not present in the drop down list.

This is because the Response form contains a subform which contains this field. In order to bind to the field, you currently must type the name of the subform manually in the Data Binding field.