資料

[資料]標籤頁定義表單屬性,這些屬性針對與表單連結的資料庫。

定義表單使用的資料源,或者指定使用者是否可以編輯資料。除了排序和篩選功能外,您還可以找到建立子表單所需的全部屬性。

若要使用此指令...

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

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


修改資料

Determines if the data can be modified.

允許刪除

Determines if the data can be deleted.

內容

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.

如果在 [內容類型] 中選取了「表格」或「查詢」,則該方塊中會列出選取的資料庫中設定的所有表格和查詢。

分析 SQL 指令

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.

只增加資料

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

note

如果將[僅新增資料]設定為「是」,則無法變更或刪除資料。


增加資料

Determines if data can be added.

循環

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:

選項

涵義

預設

此設定可使現存的資料庫連結的做自動循環。若表單中存有資料庫連結,以製符鍵在退出最後一個欄位時,會跳到下一個/前一個資料條目 (如所有資料條目所示)。若無資料庫連結則會跳到下一個表單 (如此頁所示)。

全部資料條目

此選項僅適用於資料庫表單,用於瀏覽所有的資料條目。如果您使用 TAB 鍵退出表單的最後一個欄位,則會變更目前的資料條目。

目前的資料條目

此選項僅適用於資料庫表單,用於瀏覽目前的資料條目。如果您使用 TAB 鍵退出表單的最後一個欄位,則會變更目前的資料條目。

目前頁面

退出表單的最後一個欄位時,游標會跳至下一表單的第一個欄位。對於 HTML 表單而言,這是標準設定,因此,此選項對於 HTML 表單尤為重要。


排序

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

在使用者模式中,可以使用 [表單瀏覽] 工具列中的相應圖示進行排序:[向上排序][向下排序][排序]

瀏覽位址列

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

[父表單] 選項用於子表單。若為子表單選擇此選項,則可在游標位於子表單時,使用主表單的條目進行瀏覽。由於子表單按照 1:1 關係連結到父表單,因此一律會在父表單上執行瀏覽。

篩選

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.

在使用者模式下,可以透過 [表單瀏覽] 工具列中的 [自動篩選] [表單瀏覽] 圖示使用篩選功能。

資料來源

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.

資料源類型

定義是否使用現有的資料庫表格或查詢作為資料來源,或者是否基於 SQL 陳述式來產成表單。

如果您選擇「表格」或「查詢」,則表單將會參考您在資料來源底下指定的表格或查詢。如果您想要建立一個新的查詢或子表單,則您必須選擇「SQL」選項。接著您可以直接在 [清單內容] 方塊中輸入 SQL 查詢或子表單的陳述式。表單隨後會在指定陳述的基礎下產生。

連結從

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.

如下範例所示:

例如,在一個資料庫表格中設定客戶資料庫 (「客戶」),在其中您將客戶一一編號並納入名稱為「Customer_ID」的表格欄位中。而用其他的資料庫表格管理客戶的訂單資料。現在,您在表單中鍵入客戶名稱時,也想同看到此客戶的訂單資料。所以,請先進入子表單,然後在「連結從」下輸入客戶資料庫的資料欄位,也就是「Customer_ID」。在「連結至」中填入一個可以套用在「Customer_ID」的變數名稱,例如:「X」。

子表單應顯示訂單表格 (「Orders」) 中每個客戶 ID 對應的資料 (Customer_ID -> x)。前提是,在訂單表格中將每個訂單唯一指定給一個客戶。您也可以使用另一個名為 Customer_ID 的欄位,但為確保此欄位不與主表單中的 Customer_ID 欄位混淆,可以將其命名為 Customer_Number。

現在請比較「Orders」表格中的 Customer_Number 和「Customers」表格中的 Customer_ID,比較時可以使用 x 變量和以下 SQL 陳述式:

SELECT * FROM 訂單 WHERE Kunden_Nr =: x (若要子表單顯示「訂單工作表」的全部資料)

或:

SELECT Articel FROM Bestellungen WHERE Kunden_Nr =: x (若要子表單自顯示「訂單工作表」中的「Article」欄位資料)

您可以在「資料源」欄位中輸入 SQL 陳述式,或是設定藉以建立子表單的參數查詢。

連結至

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.

例如,若是您在作為上一層欄位的「連結從」下輸入「CustomerID」資料庫欄位,則便可在「連結至」 下設定可在其中讀取「CustomerID」資料庫欄位數值的變量名稱。如果您現在在「資料源」欄位中透過變量來指定某個 SQL 陳述,則便會在子表單中會顯示出對應的數值。

什麼是子表單呢?

表單是依據資料庫表格或資料庫查詢所建立的。先整理好資料,並且可以用來重新輸入或是變更已現存的資料,可在依據表單的資料庫表格或查詢中儲存這些資料。

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.

子表單是主表單的附加元件。主表單可稱為「父表單」或「主控表單」。當您希望從表單中存取多個表格時即需要子表單。每個附加的表格其本身都需要子表單。

建立表單後,可以變更為子表單。若要執行此作業,輸入 [設計模式],並開啟 [表單助手]。在 [表單助手] 中,拖曳表單 (將成為子表單) 至其他表單 (將成為主表單)。

您文件的使用者將不會看見表單中還有子表單。使用者只會看見已輸入資料的文件或是顯示現有資料的文件。

指定主表單中資料欄位內的 [連結] 主欄位。在子表單中,可將 [連結] 從屬欄位的內容設為與 [連結] 主欄位內容相同。

當使用者瀏覽資料時,表單一律顯示目前的資料記錄。如果定義了子表單,子表單內容的顯示將會稍微延遲約 200 毫秒。此延遲讓您迅速瀏覽主表單的資料記錄。如果您在該段延遲期間瀏覽至下一筆主資料記錄,則不會擷取及顯示子表單資料。

Please support us!