|
|
|
|
|
- Method 1: Table controls linked by the Filter property
- Creating the first Table control
- Creating the second Table control
- Establishing the link between the Table controls
- Using queries
- Creating the query
- Creating the second Table control
- Establishing the link between the Table controls
How to create two linked cascading tables?
We name cascading Tables two Table controls whose content is linked. For example: - Display families of products in a Table control.
- For each family selected in the Table control, display the products that belong to it in a second Table control.
This help page explains how to create cascading Tables: Method 1: Table controls linked by the Filter property When the Filter property is used on a Table control, it allows you to filter the content of the control based on a value. This value is checked in relation to the search item defined for the Table control. The filter is applied to the second Table control. The row selection code enables the filter. In this example, the customers of the CUSTOMER data file will be displayed in the main Table control. The second Table control will contain the orders of the customer selected in the first Table control. The steps for creating these 2 cascading Table controls are as follows: - Creating the first Table control.
- Creating the second Table control.
- Link between the two Table controls.
Creating the first Table control - Create a window if necessary.
- In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
Click where you want to create the Table control in the window.
- The Table control creation wizard starts.
- Select "Display data from a file or existing query".
Go to the next step of the wizard.
- Select the file associated with the Table control. In our example, the CUSTOMER file.
Go to the next step of the wizard. - Select the items that will be displayed in the Table control. In our example, the CustomerName, Company, ZipCode and City items.
Go to the next step of the wizard. - Select the search key. In our example, the CustomerNum item.
Go to the next step of the wizard. - Since the other steps are not required for our example, you can exit the wizard.
- Validate. The Table control is automatically created in the window.
- Change the control height with the sizing handles.
Creating the second Table control The second Table control will be created in the same way. - In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
Click where you want to create the second Table control in the window (below the first one).
- The Table control creation wizard starts.
- Select "Display data from a file or existing query".
Go to the next step of the wizard.
- Select the file associated with the Table control. In our example, the CUSTOMER data file.
Go to the next step of the wizard. - Select the items that will be displayed in the Table control. In our example, we are going to select the OrderNum, OrderDate, TotalBT and TotalIOT items.
Go to the next step of the wizard. - Select the search key. Caution, the search key must be the item that establishes the link with the first Table control. In our example, this item is CustomerNum.
Go to the next step of the wizard. - Since the other steps are not required for our example, you can exit the wizard.
- Validate. The Table control is automatically created in the window.
Establishing the link between the Table controls To establish the link between the Table controls, you must: - Make sure that the first Table control returns the value that will be used to filter the second Table control. This can be defined in the Table control description ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
- Open the description of the first Table control ("Table description" option in the context menu of the control).
- In the "Content" tab, select the item to store ("Stored item" option). In our example, this option corresponds to the CustomerNum item:
- Validate the window.
- Enable the filter in the second Table control with the Filter property.
- Select the first Table control and open the control events (F2 key).
- Go to the "Select a row" event in the Table control to enter the following code:
SecondTableName.Filter = FirstTableName In our example, the corresponding code is:
The two Table controls are linked. Test the window (click GO in the quick access buttons). Select a customer in the first Table control. The result appears immediately.
This method uses a query to create and filter the records in the second Table control. In this example, the customers of the CUSTOMER data file will be displayed in the main Table control. The second Table control will contain the orders of the customer selected in the first Table control. The steps for creating these 2 cascading tables are as follows: - Creating the first Table control (this step is the same as the one of the first method).
- Creating a query with filter used to select the records corresponding to the row selected in the first Table control. This query will be used as source for the second Table control.
- Creating the second Table control.
- Link between the two Table controls.
Creating the first Table control - Create a window if necessary.
- In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
Click where you want to create the Table control in the window.
- The Table control creation wizard starts.
- Select "Display data from a file or existing query".
Go to the next step of the wizard.
- Select the file associated with the Table control. In our example, the CUSTOMER file.
Go to the next step of the wizard. - Select the items that will be displayed in the Table control. In our example, the CustomerName, Company, ZipCode and City items.
Go to the next step of the wizard. - Select the search key. In our example, the CustomerNum item.
Go to the next step of the wizard. - Since the other steps are not required for our example, you can exit the wizard.
- Validate. The Table control is automatically created in the window.
- Change the control height with the sizing handles.
Creating the query The steps to create an SQL query with filter are as follows: - Click in the quick access buttons.
- In the window that is displayed, click "Queries".
- The query creation wizard starts.
- Specify that you want to create a select query ("Select" option).
Go to the next step of the wizard. - The query description window appears.
- Give a name and a caption to the query:
- In the left section of the description window, select the data file items that will be used (in our example, the ORDER file and the CustomerNum, OrderNum, OrderDate, TotalBT and TotalIOT items).
- Double-click the names of the items to add them to the list of query items:
- To apply the filter (selection), select the CustomerNum item in the middle section then, in the right section of the editor, click "Selection condition".
- In the menu that appears, select "New condition...".
- In the window that appears:
- Select the operation ("is equal to" in our example).
- Select "Parameter" to be able to pass a value selected in the first Table control to the query.
- Validate. The query description window is updated:
- Validate the query description window. The query is displayed in the editor:
- Save the query (Ctrl + S).
Creating the second Table control To create the second Table control: - Create a window if necessary.
- In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
Click where you want to create the Table control in the window.
- The Table control creation wizard starts.
- Select "Display data from a file or existing query".
Go to the next step of the wizard.
- Select the query previously created to associate it with the Table control. In our example, the QRY_CustomerOrder query.
Go to the next step of the wizard. - Select the items that will be displayed in the table. In our example, the OrderNum, OrderDate, TotalBT and TotalIOT items are selected.
Go to the next step of the wizard. - Since the other steps are not required for our example, you can exit the wizard.
- Validate. The second Table control is automatically created.
Establishing the link between the Table controls To establish the link between the Table controls, you must: - Make sure that the first Table control returns the value that will be used to filter the query content. This can be defined in the Table control description ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
- Open the description of the first Table control ("Table description" option in the context menu of the control).
- In the "Content" tab, select the item to store ("Stored item" option). In our example, this option corresponds to the CustomerNum item:
- Validate the window.
- Initialize the parameter of the query used by the second Table control.
- Select the first Table control and open the control events (F2 key).
- Go to the "Selecting a row of..." event to enter the following code:
QueryName..ParameterName = FirstTableName HExecuteQuery(QueryName) TableDisplay(SecondTableName) In our example, the corresponding code is:
The two Table controls are linked. Test the window (click GO in the quick access buttons). Select a customer in the first table. The result appears immediately.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|