Example of creation of user form with use of the several linked tables

Print Top page

Let's consider construction of the user form with several tables linked with each other.

 

Schedule_flights form displays information on the airports. There is Airports (Air_Map.dbf) table, containing the list of airports. Also it is required, that the user, moving along this table, saw not only names of the airports, but also the list of flight directions (Air_Town.dbf), and also the list of destination place of flight (Air_Time.dbf).

In this case Air_Map.dbf table is main table, Air_Town.dbf table is auxiliary one, and a key defining their links are Name and Airport fields of the given tables accordingly. Air_Map.dbf table should be indexed by Name field, which will be a key for link of tables. Link between Air_Town.dbf and Air_Time.dbf. tables is similarly constructed. Air_Town.dbf table should be indexed by Airport field which will be a key for link of tables.

For creation of Schedule_flights (Расписание_рейсов) form it is necessary to execute 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 Schedule of planes flights (Расписание рейсов самолетов) to Name property.

4. Place on the form Table component. Set the value Air_Map.dbf to Table name property, Airports - to Name property, True to Active property.

5. Place onto the form Grid component. Set the value Airports to Dataset property. For Column property create a new static column, having started Editor of columns. Add a column and establish value of Field property - Name, Title - Airport.

6. Place onto the form a component "Table". Set for the Table name property the value "Air_Town.dbf" (the table is indexed by Аэропорт(Airport) field, a name of an index - Назв_Аэр (Name_Air)). Set the Flights value to the Name property, True value to Active property, the Airport value to Master dataset name. For property Master fields you must set parameters of link by means of Link editor of fields between the main and detail tables (Назв_аэр-> Название(Name)).

7. Place on the form Grid component. Set Flights value to Dataset property. Create static columns: Airport (Аэропорт) and Direction (Направ) for Columns property.

8. Place onto the form a component "Table". Set for the Table name property the value "Air_Time.dbf" (the table is indexed by Пункт field, a name of an index – Пункты_Наз). Set the Time value to the Name property, True value to Active property, Flights (Рейсы) value to Master dataset name.  For property Master fields you must set parameters of link by means of Link editor of fields between the main and detail tables (Пункты_Наз->Направ).

9. Place on the form Grid component. Set Time value to Dataset property. Create static columns: Пункт, Рейс, Самолет, Время, Дни_От. for Columns property.

10. Place on the form DB_Edit component. Set the value Airports to Dataset property, establish value of Field property - Transport.

11. Place on the form DB_Memo component. Set the value Airports to Dataset property, establish value of Field property – Information.

12. Place on the form components: Navigator, DB_Work_Panel, Work_Panel. Set the value Airports to Dataset property.

13. Save created form.

Let's open for viewing Schedule of planes flights (Расписание рейсов самолетов) form. You will see that depending on marked record in the list of the airports, the list of directions of this airport and the list of destinations will be displayed. Thus, the cursor slides along the master table (Airports), and the auxiliary table displays only those records in which key fields coincide with key fields of the main table