資料

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

若要使用此指令...

Open context menu of a selected form element - choose Control Properties - Data tab.

Open Form Design toolbar, click Control icon - Data tab.


note

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:

來源儲存格範圍

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.

參照值 (開啟)

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.

Web 表單中的參照值

若您設計 Web 表單,並要將控制項狀態資訊傳送至伺服器,參照值將非常有用。若使用者按一下控制項,對應的參照值便會傳送至伺服器。

例如,如果有兩個控制項欄位,分別針對選項「女性」和「男性」,將參照值 1 指定給「女性」欄位,2 指定給「男性」欄位,則當使用者按一下「女性」欄位時,數值 1 會傳送至伺服器,按一下「男性」欄位時,數值 2 會傳送至伺服器。

資料庫表單的參照值

同時也可以在資料庫表單下透過參照值識別選項欄位或核取方塊的狀態,以及在資料庫中儲存這個參照值。例如,若是您有三個選項的群組「運行中」、「完成」和「再次呈遞」,以及當時的參照值「ToDo」、「OK」和「WV」,則這些參照值便會顯示在資料庫中,如果按下當時的選項。

參照值 (關閉)

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.

固定的欄位

note

如果您在屬性瀏覽器中刪除 [結合欄位] 儲存格的內容,結果集的第一個欄位會用來顯示及交換資料。


這個可針對清單方塊所使用的屬性會決定,所連結工作表的哪個資料欄位會在表單中顯示。

如果表單中的清單方塊要顯示的表格內容為某表單表格之連結,請在 [清單內容類型] 欄位中定義該顯示要由 SQL 指令決定或由被存取的(連結)表格決定。借助 [綁定的欄位] 特性,您可以使用索引來指定清單欄位要連結的查詢或表格的資料欄位。

note

屬性[固定的欄位]僅用於存取一個以上表格的表單。如果該表單僅基於一個表格,則要在該表單中顯示的欄位直接在[資料欄位]下指定。然而,如果您要此清單方塊顯示透過共用資料欄位連結至目前表格的表格中的資料,則連結的資料欄位由屬性[固定的欄位]來定義。


如果您選取了[清單內容的類型]下的「SQL」,則 SQL 指令決定要指定的索引。示例:如果您指定 SQL 指令,例如[清單內容]下的「SELECT Field1, Field2 FROM tablename」,則參照下列表格:

固定的欄位

連結

-1

The index of the selected entry in the list is linked to the field specified under Data field.

{empty} or 0

「欄位 1」資料庫欄位是和在資料欄位下所指定的欄位連結。

1

「欄位 2」資料庫欄位是和在資料欄位下所指定的欄位連結。


如果您選取了[清單內容的類型]下的「表格」,則此表格結構定義要指定的索引。示例:如果在[清單內容]下已選取資料庫表格,則參照下列表格:

固定的欄位

連結

-1

The index of the selected entry in the list is linked to the field specified under Data field.

{empty} or 0

工作表的第一欄是和在資料欄位下所指定的欄位連結。

1

工作表的第二欄是和在資料欄位下所指定的欄位連結。

2

工作表的第三欄是和在資料欄位下所指定的欄位連結。


清單內容

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.

就資料庫表單而言,資料源決定清單方塊或組合方塊的條目。根據選取的類型,如果這些物件存在於資料庫中,您可在[清單內容]下的不同資料源之間進行選擇。此處提供[清單內容的類型]下所選類型的所有可用資料庫物件。如果您已選取「數值清單」選項作為類型,您可以使用資料庫表單的參照。如果此控制項的顯示由 SQL 指令來控制,則在此處輸入該 SQL 陳述式。

用於 SQL 陳述式的示例:

清單方塊的 SQL 陳述式具有下列格式:

SELECT 欄位 1,欄位 2 FROM 工作表,

其中「工作表」為其資料顯示在控制項清單中的工作表 (清單工作表)。「欄位 1」為在表單中決定顯示的條目的資料欄位,其內容會在清單方塊中顯示。「欄位 2」是清單工作表中的欄位,其中如果「固定的欄位」選取為 = 1,則這會透過在「資料欄位」下所指定的欄位和表單工作表 (數值表格) 連結。

組合方塊的 SQL 陳述式具有下列格式:

SELECT DISTINCT 欄位 FROM 工作表,

在此,「field」是清單表格「table」中的資料欄位,此表格的內容顯示在組合方塊的清單中。

HTML 文件下的數值清單

對於 HTML 表單,您可以在[清單內容]下輸入數值清單。選取[清單內容的類型]下的選項「數值清單」。此處輸入的數值在表單中將不可見,並被用於將數值指定給可見的條目。[清單內容]下建立的條目對應於 HTML 標記 <OPTION VALUE=...>。

在清單方塊或組合方塊內所選條目的資料傳輸中,此表單中所顯示數值的清單 (在[一般]標籤的[清單項目]下輸入) 與在[資料]標籤的[清單內容]下輸入的數值清單,均被考量:如果 (非空) 文字位於此數值清單 (<OPTION VALUE=...>) 中的選取位置,則它將被傳送。否則,在 (<OPTION>) 控制項中顯示的文字被傳送。

如果此數值清單要包含空字串,則在 [清單內容] 下的對應位置輸入值「$$$empty$$$」(注意字母大小寫)。LibreOffice 將此輸入解譯為空字串,並將其指定給相應的清單項目。

下述工作表會根據一個名稱為「ListBox 1」的清單方塊顯示 HTML、JavaScript 和「清單內容」LibreOffice 欄位間的關聯。藉此,「Item」會繪製一個顯示在表單中的清單項目:

HTML 標籤

JavaScript

控制項數值清單中的條目 (清單內容)

傳送會...

<OPTION>Item

不可能

""

...顯示的清單項目 ("ListBox1=Item")。

<OPTION VALUE="value">Item

ListBox1.options[0].value="value"

「數值」

...指定至清單項目的數值 ("ListBox1=value")。

<OPTION VALUE="">Item

ListBox1.options[0].value=""

"$$$empty$$$"

...空白字串 ("ListBox1=").


清單內容的類型

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

使用「數值清單」選項,在 [一般] 標籤的 [清單項目] 欄位中輸入的全部項目均顯示在此控制項中。對於資料庫表單,您可以使用參照值 (請參閱 「使用數值清單參照」 一節)。

如果此控制項的內容是從資料庫讀取的,您可以使用其他選項決定資料源的類型。例如,您可以在表格和查詢之間進行選擇。

空白字元順序為零

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."

不同資料庫系統處理 NULL 值的方式各不相同。請參閱您使用之資料庫的說明文件。

篩選建議

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.

資料欄位

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

有以下數種可能:

  1. 第一種情形:表單中僅有一個表格。

    [資料欄位]中,指定資料源表格中要顯示內容的欄位。

  2. 第二種情形:控制項屬於一個由 SQL 查詢建立的子表單。

    [資料欄位]中,指定要顯示內容的 SQL 陳述式欄位。

  1. 第三種情形:組合方塊

    在組合方塊中的調節方塊下指定目前表單工作表的欄位,可在其中儲存由使用者所輸入或選取的數值。(在組合方塊清單中所顯示的數值可以透過 SQL 陳述式決定,可在清單內容下鍵入組合方塊。)

  2. 第四種情形:清單方塊

    此資料源表格不包含要顯示的資料,但包含透過共用資料欄位連結至此資料源表格的表格。

    如果要清單方塊顯示連結至目前資料源表格的表格中的資料,請在[資料欄位]下,指定該清單方塊的內容所參照的資料源表格的欄位。或者您可以指定控制此表單中資料顯示的資料庫欄位。如果兩個表格可以透過共用資料欄位連結,則此資料欄位提供與另一個表格的連結。這個資料欄位通常儲存有唯一的識別碼。在此表單中顯示內容的資料欄位由[清單內容]下的 SQL 陳述來指定。

和參照一起執行清單方塊。這可以藉由所連結的工作表透過 SQL 陳述式來進行 (第四種情形) 或是透過數值清單:

所連結工作表中的參照 (SQL 陳述式)

如果要清單方塊顯示資料庫表格 (透過共用資料欄位連結至此表單所依據的表格) 中的資料,則此表單表格的連結欄位在[資料欄位]下指定。

如果您選取了「SQL」或「Native SQL」,則可建立與在[清單內容的類型]下的[清單內容]欄位中指定的 SQL Select 之間的連結。例如,表格「Orders」與目前的表單控制項相連結,在資料庫中表格「Customers」與表格「Orders」相連結。您可以使用如下的 SQL 陳述式:

選取「顧客名稱」,顧客中的「顧客編號」,

其中「CustomerName」是來源於相連結的表格「Customers」中的資料欄位,「CustomerNo」是表格「Customers」中的欄位,而表格「Customers」與[資料欄位]下指定的表單表格「Orders」中的一個欄位相連結。

數值清單中的參照

可以在清單方塊下使用數值清單。這些是定義參照值的清單。藉此,表單中的控制項沒有直接地顯示資料庫欄位的內容,而是透過數值清單顯示所指定的數值。

如果您使用數值清單的參照值,則您在表單中[資料欄位]下所指定的資料欄位的內容不可見,而指定的數值卻可見。如果您選擇了[資料]標籤上[清單內容的類型]下的「數值清單」,並將參照值指定給表單中[清單項目]下可見的清單項目 (在[一般]標籤中輸入),則此參照值會與給定資料欄位的資料內容相比較。如果參照值對應於資料欄位的內容,則相關聯的清單項目會顯示在此表單中。

連結儲存格的內容

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".

連結的儲存格

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:

含有連結儲存格的核取方塊

動作

結果

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:

若為三狀態核取方塊,則核取方塊將被設定為「未確定」狀態,否則,取消選取核取方塊。

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:

空白字串將被複製到儲存格。

The Reference value box contains text. Enter the same text into the cell:

已選取核取方塊。

The Reference value box contains text. Enter another text into the cell:

已取消選取核取方塊。


含有連結儲存格的選項按鈕 (單選按鈕)

動作

結果

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:

空白字串將被複製到儲存格。

The Reference value box contains text. Enter the same text into the cell:

已選取選項按鈕。

The Reference value box contains text. Enter another text into the cell:

已清除選項按鈕。


含有連結儲存格的文字方塊

動作

結果

Enter text into the text box:

Text is copied into the linked cell.

Clear the text box:

Linked cell is cleared.

Enter text or a number in the linked cell:

Text or number is copied into the text box.

Enter a formula into the linked cell:

Formula result is copied into the text box.

Clear the linked cell:

Text box is cleared.


含有連結的儲存格的數字欄位與格式化欄位

動作

結果

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.


含有連結儲存格的清單方塊

列出支援兩種不同連結模式的方塊,請參閱特性「連結的儲存格的內容」。

  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.

動作

結果

Select a single list item:

連結的內容:項目文字將被複製到連結的儲存格。

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:

清單方塊項目將根據變更來更新。已保留選取。這可能會更新連結的儲存格。


含有連結儲存格的組合方塊

動作

結果

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:

下拉式清單項目將根據變更來更新。組合方塊與連結的儲存格的編輯欄位將不會變更。


Please support us!