Data-Nominated Subforms

I thought I would post a little sample on data-nominated subforms tonight. This is a new feature, introduced in Designer 7.1, which can be a very powerful tool.

Since the feature essentially lets you define expressions against values from data being loaded into a form in order to control which subform, from a specified set (subform set containing subforms), will be used for the record currently being loaded into the form, you can do very interesting things. For example, you might have a table which lists data. Maybe you would like to use a row which has a yellow background to identify data which is not important, one with an orange background for data that’s important and one with a red background for data that’s very important. This can be easily achieved using Data-Nominated Subforms.

I’ve created a little sample based on the movie data I used for the “Conditional Breaks Sample”: I posted a few days ago. In this sample, I have a subform set which contains 3 subforms, each capable of binding to a movie record. The twist is that I want to use the green subform for comedies, the red one for action movies and the blue one for dramas.

“Download Sample [zip]“:

*Minimum Requirements:* Designer 7.1, Acrobat Pro 7.0.5.

*Note:* A basic understanding of Data Binding is required for this sample.

The trick in getting this to work is to first create a data connection which represents the data you’re loading into the form.Then you need to create the subforms which each contain fields with names set to the data node names from a movie record so that _Normal_ (“implicit”) binding works correctly once the subform is picked for the record.The next step is to wrap all subforms into a subform set. You can do this by selecting them all in the Hierarchy palette and then choosing _Wrap in Subform Set_ from the context menu.At this point you’re almost done. All that’s missing are the expressions which tell the Object Model which subform from within the subform set to use for a particular data record.The Data-Nominated Subform feature is accessed by selecting the subform set and going to the Object palette’s Subform Set tab. There, you’ll find a Type property from which you can select the _Select One Subform From Alternatives_ item. When you select this option, an _Edit Alternatives_ button will appear. Click on that to open the Data-Nominated Subform dialog. In there, you would elect to _Choose Subform Using Expression_, select your data connection from the drop down list and then specify an expression likebc. category == “Comedy”for the “$” binding (which establishes the scope for your expression) on the comedy subform.When you preview the form (if you just run it in Acrobat, you’ll have to import the data into the form using the commands under the File menu), you’ll see that the comedy subform is used only for records which have a “Comedy” category name.