Forms: Data Tab

Зміст

# Data Tab

The Data tab page allows you to assign a data source to the selected control.

Щоб скористатися цією командою…

#### From the context menu:

Choose Control Properties - Data tab.

#### From the tabbed interface:

Choose Forms - Control Properties - Data tab.

#### From toolbars:

Control Properties

For forms with database links, the associated database is defined in the Form Properties. You will find the functions for this on the Data tab page.

The possible settings of the Data tab page of a control depend on the respective control. You will only see the options that are available for the current control and context.
The following fields are available:

## Bound field

If you delete the contents of the Bound field cell in the property browser, the first field of the result set is used to display and to exchange data.

This property for list boxes defines which data field of a linked table is displayed in the form.

If a list box in the form is to display contents of a table linked to the form table, then define in the Type of list contents field if the display is determined by an SQL command or the (linked) table is accessed. With the Bound field property, you use an index to specify to which data field of the query or of the table the list field is linked.

The property Bound field is only for forms that are used to access more than one table. If the form is based on only one table, the field to be displayed in the form is specified directly under Data field. However, if you want the list box to display data from a table that is linked to the current table over a common data field, the linked data field is defined by the property Bound field.

If you selected "SQL" under Type of list contents, the SQL command determines the index to be specified. Example: If you specify an SQL command such as "SELECT Field1, Field2 FROM tablename" under List content, refer to the following table:

Bound field | Лінія
--- | ---
-1 | The index of the selected entry in the list is linked to the field specified under Data field.
{empty} or 0 | The database field "Field1" is linked to the field specified under Data field.
1 | The database field "Field2" is linked to the field specified under Data field.

If you selected "Table" under Type of list contents, the table structure defines the index to be specified. Example: If a database table is selected under List content, refer to the following table:

Bound field | Лінія
--- | ---
-1 | The index of the selected entry in the list is linked to the field specified under Data field.
{empty} or 0 | The 1st column of the table is linked to the field specified under Data field.
1 | The 2nd column of the table is linked to the field specified under Data field.
2 | The 3rd column of the table is linked to the field specified under Data field.

## Contents of the linked cell

Select the mode of linking a list box with a linked cell on a spreadsheet.

1. Linked contents: Synchronize the text contents of the selected list box entry with the cell contents. Select "The selected entry".

2. Linked selection position: The position of the single selected item in the list box is synchronized with the numerical value in the cell. Select "Position of the selected entry".

## Data field

With database forms, you can link controls with the data fields.

You have several possibilities:

1. First case: There is only one table in the form.

   Under Data field, specify the field of the data source table whose contents you want to be displayed.

2. Second case: The control belongs to a subform that is created by an SQL query.

   Under Data field, specify the field of the SQL statement whose contents you want to be displayed.

1. Third case: Combo Boxes

   For combo boxes, the field of the data source table in which the values entered or selected by the user should be stored is specified under Data field. The values displayed in the list of the combo box are based on an SQL statement, which is entered under List content.

2. Fourth case: List Boxes

   The data source table does not contain the data to be displayed, but rather a table linked to the data source table through a common data field.

   If you want a list box to display data from a table that is linked to the current data source table, under Data field specify the field of the data source table to which the content of the list box refers. Or you can specify the database field that controls the display of the data in the form. This data field provides the link to the other table if both tables can be linked through a common data field. It is usually a data field in which unique identification numbers are stored. The data field whose contents are displayed in the form is specified by an SQL statement under List content.

List boxes work with references. They can either be implemented with linked tables by SQL statements (fourth case) or through value lists:

References through linked tables (SQL statements)

If you want a list box to display data from a database table that is linked by a common data field to the table on which the form is based, the link field of the form table is specified under Data field.

The link is created with an SQL Select, which, if you selected "SQL" or "Native SQL", is specified under Type of list contents in the field List content. As an example, a table "Orders" is linked to the current form control, and in the database a table "Customers" is linked to the "Orders" table. You can use an SQL statement as follows:

SELECT CustomerName, CustomerNo FROM Customers,

where "CustomerName" is the data field from the linked table "Customers", and "CustomerNo" is the field of the table "Customers" that is linked to a field of the form table "Orders" specified under Data field.

References Using Value Lists

For list boxes, you can use value lists. Value lists are lists that define reference values. In this way, the control in the form does not directly display the content of a database field, but rather values assigned in the value list.

If you work with reference values of a value list, the contents of the data field that you specified under Data Field in the form are not visible, but rather the assigned values. If you chose "Valuelist" on the Data tab under Type of list contents and assigned a reference value to the visible list entries in the form under List entries (entered in the General tab), then the reference values are compared with the data content of the given data field. If a reference value corresponds to the content of a data field, the associated list entries are displayed in the form.

## Empty string is NULL

Defines how an empty string input should be handled. If set to "Yes", an input string of length zero will be treated as a value NULL. If set to "No", any input will be treated as-is without any conversion.

An empty string is a string of length zero (""). Normally, a value NULL is not the same as an empty string. In general, a term NULL is used to denote an undefined value, an unknown value, or "no value has been entered yet."

Database systems vary and they might handle a value NULL differently. Refer to documentations of the database that you are using.

## Filter proposal

While designing your form, you can set the "Filter proposal" property for each text box in the Data tab of the corresponding Properties dialog. In subsequent searches in the filter mode, you can select from all information contained in these fields. The field content can then be selected using the AutoComplete function. Note, however, that this function requires a greater amount of memory space and time, especially when used in large databases and should therefore be used sparingly.

## Linked cell

Specifies the reference to a linked cell on a spreadsheet. The live state or contents of the control are linked to the cell contents. The following tables list the controls and their corresponding link type:

### Check box with linked cell

Action | Result
--- | ---
Select the check box: | TRUE is entered into the linked cell.
Deselect the check box: | FALSE is entered into the linked cell.
Tri-state check box is set to "undetermined" state: | #NV is entered into the linked cell.
Enter a number or a formula that returns a number in the linked cell: | If entered value is TRUE or not 0: Check box is selected. If entered value is FALSE or 0: Check box is deselected.
Clear the linked cell, or enter text, or enter a formula that returns text or an error: | Check box is set to "undetermined" state if it is a tri-state check box, else check box is deselected.
Select the box. The Reference value box contains text: | The text from the Reference value box is copied to the cell.
Deselect the box. The Reference value box contains text: | An empty string is copied to the cell.
The Reference value box contains text. Enter the same text into the cell: | The check box is selected.
The Reference value box contains text. Enter another text into the cell: | The check box is deselected.

### Option button (radio button) with linked cell

Action | Result
--- | ---
Select the option button: | TRUE is entered into the linked cell.
Option button is deselected by selecting another option button: | FALSE is entered into the linked cell.
Enter a number or a formula that returns a number in the linked cell: | If entered value is TRUE or not 0: Option button is selected. If entered value is FALSE or 0: Option button is deselected.
Clear the linked cell, or enter text, or enter a formula that returns text or an error: | Option button is deselected.
Click the option button. The Reference value box contains text: | The text from the Reference value box is copied to the cell.
Click another option button of the same group. The Reference value box contains text: | An empty string is copied to the cell.
The Reference value box contains text. Enter the same text into the cell: | The option button is selected.
The Reference value box contains text. Enter another text into the cell: | The option button is cleared.

### Текстове поле з пов'язаною коміркою

Дія | Результат
--- | ---
Введення тексту в текстове поле: | Текст копіюється у пов'язану комірку.
Очищення текстового поля: | Пов'язана комірка очищається .
Введення тексту або числа в пов'язану комірку: | Текст або число копіюється в текстове поле.
Введення формули в пов'язану комірку: | Результат формули копіюється в текстове поле.
Очищення пов'язаної комірки: | Текстове поле очищається.

### Numerical field and formatted field with linked cell

Action | Result
--- | ---
Enter a number into the field: | Number is copied into the linked cell.
Clear the field: | Value 0 is set in the linked cell.
Enter a number or a formula that returns a number in the linked cell: | Number is copied into the field.
Clear the linked cell, or enter text, or enter a formula that returns text or an error: | Value 0 is set in the field.

### List box with linked cell

List boxes support two different linking modes, see the property "Contents of the linked cell".

1. Linked contents: Synchronize the text contents of the selected list box entry with the cell contents.

2. Linked selection position: The position of the single selected item in the list box is synchronized with the numerical value in the cell.

Action | Result
--- | ---
Select a single list item: | Contents are linked: Text of the item is copied into the linked cell. Selection is linked: Position of the selected item is copied into the linked cell. For example, if the third item is selected, the number 3 will be copied.
Select several list items: | #NV is entered into the linked cell.
Deselect all list items: | Contents are linked: Linked cell is cleared. Selection is linked: Value 0 is entered in the linked cell.
Enter text or a number into the linked cell: | Contents are linked: Find and select an equal list item. Selection is linked: The list item at the specified position (starting with 1 for the first item) is selected. If not found, all items are deselected.
Enter a formula into the linked cell: | Find and select a list item that matches the formula result and link mode.
Clear the linked cell: | Deselect all items in the list box.
Change the contents of the list source range: | List box items are updated according to the change. The selection is preserved. This may cause an update to the linked cell.

### Combo box with linked cell

Action | Result
--- | ---
Enter text into the edit field of the combo box, or select an entry from the drop-down list: | Text is copied into the linked cell.
Clear the edit field of the combo box: | Linked cell is cleared.
Enter text or a number into the linked cell: | Text or number is copied into the edit field of the combo box.
Enter a formula into the linked cell: | Formula result is copied into the edit field of the combo box.
Clear the linked cell: | Edit field of the combo box is cleared.
Change the contents of the list source range: | Drop-down list items are updated according to the change. The edit field of the combo box and the linked cell are not changed.

## List content

With database forms, specifies the data source for the list content of the form-element. This field can be used to define a value list for documents without a database connection.

In the case of database forms, the data source determines the entries of the list or combo box. Depending on the selected type, you have a choice between different data sources under List content, provided that these objects exist in your database. All available database objects of the type selected under Type of list contents are offered here. If you have selected the "Value List" option as the type, you can use references for database forms. If the display of the control is controlled by an SQL command, the SQL statement is entered here.

Examples of SQL statements:

For list boxes, an SQL statement may have the following form:

SELECT field1, field2 FROM table,

Here "table" is the table whose data is displayed in the list of the control (list table). "field1" is the data field that defines the visible entries in the form; its content is displayed in the list box. "field2" is the field of the list table that is linked to the form table (value table) through the field specified under Data field if Bound field = 1 was selected.

For combo boxes, an SQL statement may take the following form:

SELECT DISTINCT field FROM table,

Here "field" is a data field from the list table "table" whose content is displayed in the list of the combo box.

Value lists for HTML documents

For HTML forms, you can enter a value list under List content. Select the option "Valuelist" under Type of list contents. The values entered here will not be visible in the form, and are used to assign values to the visible entries. The entries made under List content correspond to the HTML tag <OPTION VALUE=...>.

In the data transfer of a selected entry from a list box or a combo box, both the list of the values displayed in the form, which was entered on the General tab under List entries, and the value list entered on the Data tab under List content, are taken into consideration: If a (non-empty) text is at the selected position in the value list (<OPTION VALUE=...>), it will be transmitted. Otherwise, the text displayed in the (<OPTION>) control is sent.

If the value list is to contain an empty string, enter the value "$$$empty$$$" under List content at the corresponding position (note uppercase/lowercase). LibreOffice interprets this input as an empty string and assigns it to the respective list entry.

The following table shows the connections between HTML, JavaScript, and the LibreOffice field List content using an example list box named "ListBox1". In this case, "Item" designates a list entry visible in the form:

HTML Tag | JavaScript | Entry in value list of the control (List content) | Transmitted data
<OPTION>Item | Not possible | "" | the visible list entry ("ListBox1=Item")
<OPTION VALUE="Value">Item | ListBox1.options[0].value="Value" | "Value" | The value assigned to the list entry ("ListBox1=Value")
<OPTION VALUE="">Item | ListBox1.options[0].value="" | "$$$empty$$$" | An empty string ("ListBox1=")

## Reference value (off)

Check boxes and radio buttons in spreadsheets can be bound to cells in the current document. If the control is enabled, the value you enter in Reference value (on) is copied to the cell. If the control is disabled, the value from Reference value (off) is copied to the cell.

## Reference value (on)

You can assign a reference value to option buttons and check boxes. The reference value will be remitted to a server when sending the web form. With database forms the value entered here will be written in the database assigned to the control field.

Reference values for web forms

Reference values are useful if you design a web form and the information on the status of the control is to be transmitted to a server. If the control is clicked by the user, the corresponding reference value is sent to the server.

For example, if you have two control fields for the options "feminine" and "masculine", and assign a reference value of 1 to the field "feminine" and the value 2 to the "masculine" field, the value 1 is transmitted to the server if a user clicks the "feminine" field and value 2 is sent if the "masculine" field is clicked.

Reference values for database forms

For database forms, you can also characterize the status of an option or a check box by a reference value, storing it in the database. If you have a set of three options, for example "in progress", "completed", and "resubmission", with the respective reference values, "ToDo", "OK", and "RS", these reference values appear in the database if the respective option is clicked.

## Source cell range

Enter a cell range that contains the entries for a list box or combo box on a spreadsheet. If you enter a multi-column range, only the contents of the leftmost column are used to fill the control.

## Type of list contents

Determines the data to fill the lists in list and combo boxes.

With the "Valuelist" option, all entries entered in the List entries field of the General tab appear in the control. For database forms, you can use reference values (see the References Using Value Lists section).

If the content of the control is read from a database, you can determine the type of the data source with the other options. For example, you can choose between tables and queries.

Пов'язані теми

General Tab

Events Tab

Будь ласка, підтримайте нас!