Creating Subforms

Subforms are forms that you can't use on their own, but that you can directly orprogrammatically insert into a form. In fact, a subform is just a part or segment of a whole form. Subforms provide a way to create reusable segments of a form that can be shared with multiple forms within the application. The process for creating a subform is the same as for creating forms. You can use the same design elements.

Apply a subform to a form by opening a form in design mode and placing the cursor where you want the subform to appear. At the point of insertion, select the Create Insert Subform option from the menu and choose the appropriate subform to place it in the designated location. Figure 7.14 displays the result of adding a subform directly to a form.

Figure 7.14. The RespBanner subform added to the Response form for a discussion database can be used in other forms.

If you add a subform as a computed subform, the subform itself is not displayed, but a placeholder is added instead. By clicking inside the placeholder, you can then add the appropriate formula, as displayed in Figure 7.15. A computed subform allows you to determine which subform is shown based on who the user is, the role he or she belongs to, the contents of a field, or any other condition you can think of. You can even add the day of the week.

Figure 7.15. A computed subform displays a different subform based on the specified condition.

Категории