Version 4.24 introduced a new feature to the Custom Forms, called SubForms. With the SubForm feature, a user may edit a table within a form. In order to utilize this new tool, the user is required to link two custom forms which target two different tables and are linked via a Foreign Key relationship. Below we will explain how to do this link and demonstrate how to use this feature.

Using SubForms

For this example, we are 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 one order. This basket can contain one or more requests. Each request can contain one or more products. So for example, if you imagine a supermarket basket that contains 6 eggs and 4 apples, the request would be for 6 of the product egg and 4 of the product apples.

How to Create SubForms

As mentioned already, in order to use the subforms you need to create first the forms as usual, as described in the Custom Forms article. The only thing different is that in the Form Fields excel sheet, now you will find a new column SUBFORM_CODE, in which you type the code of the SubForm you created. For this article we will create two forms the ADD_BASKET and the ADD_REQUEST. With the ADD_BASKET form, the user is creating a Basket, which will contain requests, and specify all the characteristics like request date, who is the requestor etc. In the ADD_REQUEST, the user is creating a request for the products as mentioned above, and assigning it to an existing basket via the Basket ID.

Note: Every basket may contain multiple requests.

In order to make the link between the main (ADD_BASKET) form and the SubForm (ADD_REQUEST), you need to add a new row in the Form Fields sheet of the main form, as if you are about to add a new field but in this case you have to leave the FIELD_CODE empty.

Image showing the Excel spreadsheet for creating forms. At the top, there are two pieces of text highlighted. Under 'Target Table Field Code', the text 'Required for fields; leave empty if s subform'. In the next column the header 'Sub forms to display in parent form' is highlighted. On the third row, there is an example where the Field Code has been left empty and the sub forms column has 'ADD_BASKET' in it

A small note, on this is the SEQUENCE column. In this example we have assigned the subform field as the third in this form. This will determine the order in the view data page and the exact place of where the table to enter data using the subform will appear. A suggestion is to set it as last, but we will demo the both cases in order to check the differences.

How to Use SubForms

To demonstate the SubForms feature we will use an example of two forms the ADD_BASKET and the ADD_REQUEST, as mentioned above.

Let’s see how you may create a basket and afterwards how you may add products in this basket, without opening the ADD_REQUEST form.

In the print screen below you may see that we are creating a new Basket. We have assigned a unique ID for the basket (BASKET_ID_FULL), and afterwards we enter some data to all the other fields and then we may save our entry.

Image showing a form with 'Add New Record' at the top. The fields shown are 'Basket Short ID (required)', 'Request Date', 'Contact First Name', 'Contact Last Name'. There are other foedls but they are not visible

After saving our entry, we are able to view our data and from that view, users have now the ability to view or add new data through the subform function.

Image showing that the basket has been added in the Data View Grid

In the picture above, the subform field is the third in the sequence.

Image showing one line at the top of the Data View Grid. There is a column titled 'Add Request' with two options in text, 'View', which is in black and 'Add' which is in blue

In the picture above, the subform field is set as the last in the sequence.

By clicking Add you will be the SubForm will open (ADD_REQUEST in this case) for that particular basket as you may see below and you may proceed in creating a new product for that basket.

Image showing the request form with the Basket ID populated from the parent record. The other visible field is Product which is required. At the bottom are the 'Record Check' and 'Cancel' buttons

Another way to use the SubForms is while editing the parent. If we edit a basket and scroll to the bottom, we can see that there is a grid containing the requests for this basket. of that entry you will not be able just to see the save option as usual but also the Add new record option.

Image showing the empty subforms grid with the 'Add New Record' button

By clicking the Add new record the SubForm will launch in a pop up window where you may create you entry as usual. See the screenshot below.

Image showing the 'Add new Record' screen with the Basket ID prepopulated from the parent record. The Product field is blank

When you’ll finish creating your entries using the SubForm, then you click the update button and you will be redirected back to the data view page.

Below is an example of how what you will see when you will make some entries using the subform feature.

Image showing the subform grid with 4 records in it

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.