Data

The Data tab page defines the form properties that refer to the database that is linked to the form.

Defines the data source on which the form is based, or specifies whether the data can be edited by the user. Apart from the sort and filter functions, you will also find all the necessary properties to create a subform.

للوصول لهذا الأمر...

Open context menu of a selected form element - choose Form - Data tab

Open Form Controls toolbar or Form Design toolbar, click Form icon - Data tab


Add data only

Determines if the form only allows the addition of new data (Yes) or if it allows other properties as well (No).

Note Icon

If Add data only is set to "Yes", changing or deleting data is not possible.


Allow additions

Determines if data can be added.

Allow deletions

Determines if the data can be deleted.

Allow modifications

Determines if the data can be modified.

Analyze SQL command

Specifies whether the SQL statement is to be analyzed by LibreOffice. If set to Yes, you can click the ... button next to the Content list box. This will open a window where you can graphically create a database query. When you close that window, the SQL statement for the created query will be inserted in the Content list box.

Content

Determines the content to be used for the form. The content can be an existing table or a query (previously created in the database), or it can be defined by an SQL-statement. Before you enter a content you have to define the exact type in Content type.

If you have selected either "Table" or "Query" in Content type, the box lists all the tables and queries set up in the selected database.

Content type

Defines whether the data source is to be an existing database table or query, or if the form is to be generated based on an SQL statement.

If you choose "Table" or "Query", the form will refer to the table or query that you specify under Content. If you want to create a new query or a subform, then you have to choose the "SQL" option. You can then enter the statement for the SQL query or the subform directly in the List content box on the Control properties Data tab page.

Cycle

Determines how the navigation should be done using the tab key. Using the tab key, you can move forward in the form. If you simultaneously press the Shift key, the navigation will follow the opposite direction. If you reach the last (or the first) field and press the tab key again, it can have various effects. Define the key control with the following options:

Option

معنى

افتراضي

This setting automatically defines a cycle which follows an existing database link: If the form contains a database link, the Tab key will, by default, initiate a change to the next or previous record on exit from the last field (see All Records). If there is no database link the next/previous form is shown (see Current Page).

All records

This option applies to database forms only and is used to navigate through all records. If you use the Tab key to exit from the last field of a form, the current record is changed.

Active record

This option applies to database forms only, and is used to navigate within the current record. If you use the Tab key to exit from the last field of a form, the current record is changed.

Current page

On exit from the last field of a form, the cursor skips to the first field in the next form. This is standard for HTML forms; therefore, this option is especially relevant for HTML forms.


Filter

Enter the required conditions for filtering the data in the form. The filter specifications follow SQL rules without using the WHERE clause. For example, if you want to display all records with the "Mike" forename, type into the data field: Forename = 'Mike'. You can also combine conditions: Forename = 'Mike' OR Forename = 'Peter'. All records matching either of these two conditions will be displayed.

The filter function is available in user mode through the AutoFilter and Default Filter icons on the Form Navigation Bar.

Link master fields

If you create a subform, enter the data field of the parent form responsible for the synchronization between parent and subform. To enter multiple values, press Shift + Enter after each input line.

The subform is based on an SQL query; more specifically, on a Parameter Query. If a field name is entered in the Link master fields box, the data contained in that field in the main form is read to a variable that you must enter in Link slave fields. In an appropriate SQL statement, this variable is compared to the table data that the subform refers to. Alternatively, you can enter the column name in the Link master fields box.

Consider the following example:

The database table on which the form is based is, for example, a customer database ("Customer"), where every customer has been given a unique number in a data field named "Cust_ID". A customer's orders are maintained in another database table. You now want to see each customer's orders after entering them into the form. In order to do this you should create a subform. Under Link master fields enter the data field from the customer database which clearly identifies the customer, that is, Cust_ID. Under Link slave fields enter the name of a variable which is to accept the data of the field Cust_ID, for example, x.

The subform should show the appropriate data from the orders table ("Orders") for each customer ID (Customer_ID -> x). This is only possible if each order is uniquely assigned to one customer in the orders table. Alternatively, you can use another field called Customer_ID; however, to make sure that this field is not confused with the same field from the main form, the field is called Customer_Number.

Now compare the Customer_Number in the "Orders" table with the Customer_ID from the "Customers" table, which can be done, for example, using the x variable with the following SQL statement:

SELECT * FROM Orders WHERE Customer_Number =: x (if you want the subform to show all data from the orders table)

or:

SELECT Item FROM Orders WHERE Customer_Number =: x (if you want the subform from the orders table to show only the data contained in the "Item" field)

The SQL statement can either be entered in the Data source field, or you can create an appropriate parameter query, which can be used to create the subform.

Link slave fields

If you create a subform, enter the variable where possible values from the parent form field can be stored. If a subform is based on a query, enter the variable that you defined in the query. If you create a form using an SQL statement entered in the Data source field, enter the variable you used in the statement. You can choose any variable name. If you want to enter multiple values, press Shift + Enter.

If, for example, you specified the Customer_ID database field as a parent field under Link master fields, then you can define under Link slave fields the name of the variable in which the values of the Customer_ID database field are to be stored. If you now specify an SQL statement in the Data source box using this variable, the relevant values are displayed in the subform.

Navigation bar

Specifies whether the navigation functions in the lower form bar can be used.

The "Parent Form" option is used for subforms. If you choose this option for a subform, you can navigate using the records of the main form if the cursor is placed in the subform. A subform is linked to the parent form by a 1:1 relationship, so navigation is always performed in the parent form.

Sort

Specifies the conditions to sort the data in the form. The specification of the sorting conditions follows SQL rules without the use of the ORDER BY clause. For example, if you want all records of a database to be sorted in one field in an ascending order and in another field in a descending order, enter Forename ASC, Name DESC (presuming Forename and Name are the names of the data fields).

The appropriate icons on the Form Navigation Bar can be used in User mode to sort: Sort Ascending, Sort Descending, Sort.

مصدر بيانات

Defines the data source to which the form should refer. If you click the ... button, you call the Open dialog, where you can choose a data source.

What is a subform?

Forms are created based on a database table or database query. They display the data in a visually pleasant fashion and can be used to enter data or edit data.

If you require a form that can refer to the data in a table or query and can additionally display data from another table, you should create a subform. For example, this subform can be a text box that displays the data of another database table.

A subform is an additional component of the main form. The main form can be called the "parent form" or "master". Subforms are needed as soon as you want to access more than one table from a form. Each additional table requires its own subform.

After creating a form, it can be changed into a subform. To do this, enter Design Mode, and open the Form Navigator. In the Form Navigator, drag a form (that will become a subform) onto any other form (that will become a master).

The user of your document will not see that a form has subforms. The user only sees a document in which data is entered or where existing data is displayed.

Specify the Link master field from the data fields in the master form. In the subform, the Link slave field can be set as a field which will be matched to the contents of the Link master field.

When the user navigates through the data, the form always displays the current data record. If there are subforms defined, the contents of the subforms will be displayed after a short delay of approximate 200 ms. This delay enables you to quickly browse through the data records of the master form. If you navigate to the next master data record within the delay limit, the subform data need not be retrieved and displayed.