Data module

Print Previous page Top page Next page

Data module represents the container for allocation of not visual components of a data access: table, detail table, query, parameterized query. Data module is used for providing of the centralized access to components - data sets and their fields.

For creating of a new data module select Data modules bookmark in Base Administrator and actuate Add button. After that the window of Form constructor with Data module will appear on the screen. To add the new data module in the Form constructor select menu command Data module / New or click on the icon ici_9140 of toolbar. As a result the new data module with name Data_module1 will be added. User can change this name, having set new value to property Name in Object inspector. On the form of Data module it is possible to place one or several components of Data access, and they can be of one type.

Data modules are expedient for using in cases, when one user's form should use operations results of other user's form. For example, in one user's form the results of parameterized query are displayed as the tables, and in other user's form the parameters for this query are entered, and the query is executed.

Usage example of data module.

Let's consider usage of Data_module1 at creation of user's forms "Запрос_списка_рейсов" and "Список_рейсов".

The form "Список_рейсов" (flights list) displays the information, criteria of search which are forming in the form "Запрос_списка_рейсов" (query of flights list). Both forms will work with the same data source - ПарамЗапросВремяВылета, which is arranged in Data_module1.

For creation of the form "Запрос_списка_рейсов" is necessary to do operations:

1. In User form bookmark of Base Administrator to click Add button. The Form constructor will be actuated.

2. Create a new form (command Form / New, or click Create new form button).

3. Set the value "Запрос_списка_рейсов" to Name property.

4. Place on the form Value_edit1 component. With the help of this component the demanded departure time is set.

5. Place on the form Value_edit2 component. With the help of this component the demanded place of destination is set.

6. Place on the form Operator_combobox1 component. With the help of this component the logical search operator is set. Let's select value AND (logical AND).

7. Place on the form Macros_list1 component. Add new macros Form_macros1. Set the  "CreateParam.Query" value to property Macros type. To property Param. query it is necessary to assign a component's name "Parameterized query", which will provide access to data. Let's arrange this component on Data module.

For creation of Data_module1 it is necessary to do operations:

1. Create a new Data_module (menu command Data module / New or press ici_9140 icon).

2. Place  onto Data_module1 the component Parameterized query - ПарамЗапросВремяВылета.

    To Database path property we shall assign value

      'c:\Panorama7\DATA\PODOLSK\DataBase'.

    Let's form the Query text:                                  

    SELECT * FROM AIR_TIME WHERE

    (AIR_TIME.DESTINATION = $Запрос_списка_рейсов.Value_edit2'$)

      #Запрос_списка_рейсов.Operator_combobox1#

    (AIR_TIME.TIME = $'Запрос_списка_рейсов.Value_edit1'$)

3. Save Data_module1.

8. Let's go on to fill in values of properties for Form_macros1 macros. Let's set the value "Data_module.ПарамЗапросВремяВылета" to Param. query property. Let's set the True

value to Auto execution property. If you set True value the automatic execution of a query is executed, the user does not see query text.

9. Place on the form Button1 component. For Macros name property set Form_macros1 value.

10. Save the built form.

 

For creation of the form "Список_рейсов" (flights list) it is necessary to do operations:

1. create a macros "Открыть форму Запрос_Списка_рейсов" (open form "Запрос_Списка_рейсов"). Select Macroses bookmark in Base Administrator and actuate Add button. After that the dialog Macros editor will appear on the screen. Set the value "Open form" for Macros type, for Form name - Запрос_Списка_рейсов, for Macros name - "Открыть форму Запрос_Списка_рейсов".

2. To create a new form and to set Список_рейсов value for Name property.

3. To place on the form Button component. This component will fulfil the call function of the form Запрос_списка_рейсов, therefore for Macros property set the value "Открыть форму Запрос_Списка_рейсов" (to open form "Запрос_Списка_рейсов"), for Name property - "Получить список рейсов" (Receive flights list).

4. Place on the form DB grid component and assign to Dataset name property the value - "Data_module.ПарамЗапросВремяВылета".

5. Save the built form.

 Let's open for review the form "Список_рейсов". At pressing the button "Получить список рейсов" ("Receive flights list") the form Запрос_списка_рейсов will be actuated. Using the given form, we shall fill in parameters for the Parametrized query -  "Data_module.ПарамЗапросВремяВылета" and press ОК button. On the form "Список_рейсов" the flights list up to Анапа (Anapa) and departure time 12.00 hours will be formed.  

On Data_module it is possible to place some components of data access, for example, Parameterized query component  - "ПарамЗапрос_Аэропорты" (will be used by the form "Список_Аэропортов" ("Airports_list")). For this purpose it is necessary:

6. To open Data_module1 (bookmark Data modules / Change). To place onto Data_module1 a component Parameterized query - Парамет_запрос_Аэропорты (Param_query_ Airports). To Database path property we shall assign value

      'c:\Panorama7\DATA\PODOLSK\DataBase'.  Let's form the Query text:                                  

    SELECT Description, Name FROM AIR_MAP.

7. To save Data_module1.

 

_engbm5675

 

Thus, Data_module1 allows at the same time to store and to use components - data sources.