APPLICATION DESIGN
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:
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.
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
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.
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.