We will first change the properties of the label. Click on the Label object in the Form window and click on the "Data" tab in the Property Editor window if it is not already selected. Enter the text "Author" into the entry field to the right of "Label". This text will be displayed on the form.
Now we need to provide a link from the lineeditfield object to a datasource in your database from where the data will be extracted and displayed. Click on the lineditfield and then click on the "Data" tab in the Property Editor window. Click on the button marked "..." to the right of the Datasource field and select the datasource "based on table authors" (at the top of the displayed formdatasource dialog). The other fields are not of interest at this time. Click the "Add" button. Now you have linked the form field to a column in your database.
![]() | You can also use a graphical interface for defining the datasources. Click |
The next step in our objective is to display all the literature that the selected author, Goethe (or any other author), has written. To do this switch to design mode and place a gridfield object on the form. In order to make use of the selected gridfield you have to create a new datasource based on the "literature" table. --- But after clicking on the "..." button in the Property Editor window, stop! --- We only want to see the books of the selected author so there is more work to do before you push the "add" button.
The "literature" table depends on the "authors" table, i.e. any author in the "literature" table must exist in the "authors" table. So we select the already defined datasource "authors" in the "depending on" field (ignore the number in the brackets, it is a unique number for each datasource in a form). We have to tell the system how the datasources are connected, i.e. which columns are linked to each other. In the master datasource ( authors(0) ) it is the field "author_id" and in the actual datasource table (literature) it is the field "author". Select both fields and press the button with the two arrows. The linked columns names are now displayed in the listbox on the right. Finally, click the "Add" button.
Let's have a brief look at the remaining fields in the formdatasource dialog. The sorting field allows you to sort the datasource. It has the same syntax as the "ORDER BY" syntax of SQL-statements. If you want, for example, to display the literature in ascending alphabetical order just add the field name "title" into the "sorting" field. If you want a descending order add "title DESC".
If the "is readonly?" field is checked, no values of this datasource can be changed in the form. A datasource that is already readonly (e.g. all queries) will remain readonly, even if this field is not checked.
The filter field allows you to display rows of the datasource if certain conditions are met. It has the same syntax as the "WHERE" syntax of SQL-statements.
Finally, let's create a button on our form. We will define it as a "Close" button so we can close the current form when clicked. First of all we have to store the form. This can be done in two ways, either press the save button (the one with the disk) on the horizontal toolbar or click the right mouse button in "design mode" and select "Save form". When saved, create a button and change the label to "&Close". If you have selected the button object, the Property Editor will be displaying the "Action" tab. Select the action "Close form" and select the name of the form to close in the object field. Now let's test it.