With the SubForm feature, a user may edit a table within a form. In order to do this new tool, the model needs to have the a master table linked to a child table.

Example data

For this example, we are going to create a shopping backet to which the user can add items. We will be using the following model

Image showing a layout of the example that will be used. The explanation follows

In this model, there is a basket which is can contain one or more items. These items are selected from a reference table.

The tables are set up like this.

Image showing the layout of the tables.  The explanation follows

There is a Basket table called FACT_BASKET, an Items table called REF_ITEMS and a Basket Items table called FACT_BASKET_ITEMS which has Foreign Keys to the Basket table and the Items table.

Using a subform

A subform appears as a grid as part of the main form. In this case, the Basket is the main form and the Basket Items are the subform. This is because we want to attach many items to a Basket.

When you go into the main form, it appears at the bottom

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it.

To add a new item to the basket, click Add New Record. This opens a pop_up

Image showing the Basket Item pop-up with no data in it.

Fill in the fields and press Save

Image showing the Basket Item pop-up with data in it.

The item appears in the subform of the main form. Note that underneath the red box, there is a count of how many items are in the subform.

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it. There is one item in the subform

On the left of the existing records is the Subforms Action Panel

Image showing a red dustbin on the left with the caption 'Delete Record'. Next to it is a blue pencil with the caption 'Edit Record'. On the right is two interlocking squares with the one on the left higher than the one on the right with the caption 'View Record'

If you select View Record then the record will be opened but you will not be able to edit it.

As you add more rows, they are added to the list

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it. There are 3 rows in the subform

Now you can Save or Cancel the data edits

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it. There are 3 rows in the subform

Once you press save, the data is committed using a standard batch. Any changes made to either the subforn or the form are included

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it. There are 3 rows in the subform

On the Form grid, the subform items appear in a column to the right. You can either View or Add the data. If the column appears without a title then you will need to add a label to the subform

Image showing the Basket form and at the bottom is the Basket Items form with a red box around it. There are 3 rows in the subform

Clicking View will bring you to the subforms data page

Image showing the Shopping Basket Item form data page

Clicking Add will show you the subform with the relevant fields

Image showing the Shopping Basket Item form

Creating SubForms via the user interface

The easiest way to create a form with a Subform is by going to the Forms page and clicking on the Create Form button

Image showing the Create Form button on the Forms page

Enter the form code, select a table and fill out the other details.

Image showing the Tables dropdown in the Create Form window

Then scroll to the bottom and press Generate Form

Image showing the Generate Form button in the Create Form window

This willl create the form and open it.

At the top right, there is a button marked Add Field to Form

Image showing the Add Field to Form button in the Form

If you click on it, it will produce a pop-up with a list of fields which can be added.

Notice that the field which is available is a subform to the Basket Item table

Image showing the Add Field pop-up which has a title of "Pick a field or sub-form to add to the Form". There is an empty selection box and underneath is the text "FACT_BASKET_ITEM - System Form for table FACT_BASKET_ITEM"

If you click on it, you go to the Add Field panel appears on the right of the screen.

Image showing Add Field panel with 5 text boxes arranged vertically. The first is for the Label, the second for the Hint Text, Sequence, the fourth is for the Hide Expression and the last if so the Group Name

Here you can add a label, hint, sequence, hide expression, group name.

When you press the Add Field button, the subform appears.

Image showing the main form with the subform at the bottom.

Creating SubForms using files

You can create a Form using the standard method. from there, you can add a field into the subform with just the table name

So the forms tab contains the main form Image showing forms tab of the Excel with the main form as the only form being created.

And the fields tab contains the fields for the main form and one subform which is a table name. Image showing the firlds tab of the Excel with the fields for the main form and one row with a table name in the subformcolumn.

Customising SubForms

Another way to add a subform is to use an existing form. To do this, you create a custom form

In this case, I have added a form called Shopping Basket Item

Image showing the Shopping Basket Item form in the list of forms.

Nowe if we go to the main form we can see that there are 2 options to add a form, the System form or the Custom form

Image showing the Shopping Basket Item form in the list of forms which can be added to the Shopping Basket form.

Note that as soon as a subform to the referenced table is added, you cannot add another one.

Image showing that once the Shopping Basket Item form has been added, the list of forms which can be added to the Shopping Basket form is empty.

To switch form, you will need to delete the old subform and add the new one.

To add the subform in Excel, simply add its name in the subform column of the main form. You do not need to export the custom subform as well.

Image showing the Excel with the custom subform in subforms column .