"SBase Personal - 36. TRANSACTION LINES IN FORMS" 36 TRANSACTION LINES IN FORMS The Transaction Lines requester Editing Transaction Lines A Transaction Form Example Linking Files Setting the Data Entry Order for Transactions Copying Fields Creating a Table Form 36 TRANSACTION LINES IN FORMS Only in Sbase Professional 4 Many applications include one-to-many relationships between records in different files. In a form, you can define a group of fields as the `many' part of such a relationship. The term `transaction lines' refers to such a group. Typically, each transaction is a row of fields from a single record belonging to the file at the `many' end of a one-to-many relationship. Once a block of transaction lines is defined, you can enter several data records into the same file through one form. Provided all the files in the form are linked, Sbase will maintain the relationships between the transaction line records and records in other files. This allows relational browsing, in which a form shows details from many associated records at one time. To define transaction lines, follow this procedure: 1. Place all the fields that are to be part of each line on the form. 2. Select them. 3. Choose the Define Transaction Lines command. On the requester, you specify parameters for the command: - The number of transaction rows you want. - The number of blank lines that are to appear between transaction lines and rows. - The required arrangement of columns and rows. 4. Click OK. The Form Designer Pro creates the block of transaction lines. - You may only create one block of transaction lines on a form. - Provided the files are linked, only one of the common reference fields need appear on the form, and it need not appear in the transaction line block. The Transaction Lines requester *** See Fig 36-1 *** Transaction lines specifies how many times the selected group of fields and calculations will be replicated down the page: the number of transactions that will appear on the form. Line spacing determines the number of empty lines between transactions down the page. Enter a value of 0, if you wish the transactions to be placed without any spaces between them. - Row and column spacing increments are taken from the size of the largest font used for an object in the group being replicated. Transaction columns allows you to specify whether the transactions are to be arranged in a single column or across the screen in two or more columns. The total number of transactions on the form will be the number in this box times the number in the transaction lines box. If you want the form to have just one column of transactions, enter a value of 1. Column spacing only needs to be specified if you are using more than one transaction column. The number in this box determines how many spaces will be placed between each transaction across the page when there are more than one to a line. Order Down/Across buttons determine the entry order for transactions. If the form has only one column of transactions, they will automatically be numbered from top to bottom. With multiple columns, you have the option of setting the entry order from top to bottom (Down) or left to right (Across). 1 5 2 6 3 7 4 8 Clicking the Across button would ensure the entry order was as follows: 1 2 3 4 5 6 7 8 Note that this command only determines the entry order for the transaction line as a whole. It doesn't affect the order of the fields within a transaction. Editing Transaction Lines Despite their greater complexity, transactions can be edited in the Form Designer Pro in the same way as other objects on the form. Editing a transaction line includes deleting fields, adding new fields, and redefining the arrangement of a transaction block by selecting Define Transaction Lines again. To change the number of lines, first reselect the block. - This is not strictly necessary, but note that all selected fields will be included as part of the transaction lines. Now reselect the command and specify the required number of lines. Other editing activities treat the transaction lines block as a unit. So, if you change the color of a the third field along, all corresponding fields will also change. Before editing a transaction, you need to select the item or items you wish to change. This has the effect of selecting all the items of the same type in the transaction block; i.e., selecting a field in the first line automatically selects the same field in the other lines. To add a field, first place it on the form, select it in the usual way, and then select Define Transaction Lines. It is not necessary to select the fields that are already defined as transaction elements; after you have redefined the transaction block using Define Transaction Lines, the new field will be incorporated in the transactions. A Transaction Form Example Consider an example of a database application for cataloguing a book collection. It uses two files, Authors and Books. The Authors file stores the name and other details of all the authors represented in the collection, using one record for each author. The records in the Books file store the details of each book, such as its title, subject matter, and publisher. In addition, the records in both files contain an alphanumeric code (the Author_code field) which links the books to their authors. This way of organizing the data is far more flexible than a system which uses a single file to catalogue the books. It makes it easy to design a form which displays the authors and a list of their books on screen at the same time. The data would be structured as follows: F2M] F2M] F2M] F2M] Every time you selected another record in the Authors file, Sbase would read in the next author in alphabetical order followed by a variable number of lines, one for each of the author's books. The fields from a record in the Books file are treated as a single transaction; a set of transactions represents the books written by a particular author. It is possible to include fields from other files in the transaction line; in this example, each transaction line could show the publisher's address by looking it up in an address file. You would not want to amend the publisher's details from this form, so you would make all the fields from that file Read Only. Linking Files For a transaction form to work, you must establish a link between a field in the master file and a field in the transaction line using the Link command on the Set menu. Thereafter, you can set other links, but these must always be between fields in a `one-to-one' relation. In other words, you cannot set up forms where a transaction has further transactions of its own. See Chapter 38 Linking Files in Form Designer. Setting the Data Entry Order for Transactions Chapter 37 Defining Data Entry Order explains the procedures for determining the sequence used for moving from field to field during data entry. This section provides additional material relevant to transaction lines. The Define Data Entry Order command allows you to define the data entry order for the fields and calculations in a transaction in the same way as for non-transactional fields. However, there are a number of restrictions that apply when you are setting the entry order for the elements of a transaction. - The data entry order within a transaction is the same for all the transactions on the form. If you specify for one transaction that data is entered from left to right, this will also be the case for the other transactions. This means that when you are setting the entry order, you should concentrate only on the first transaction. Any changes you make will then be automatically repeated in the rest of the transactions. - If you alter the order of a transaction element with respect to other fields on the form, all the transaction order numbers will be altered at the same time (although they remain the same relative to each other). To illustrate these points, let's consider an example involving a form with four transactions each containing three fields. In addition to the transactions, there is one non-transaction field on the form above the transaction block. The fields are arranged like this: Field_a Field_b Field_c Field_d Field_b Field_c Field_d Field_b Field_c Field_d Field_b Field_c Field_d Field_a stands on its own; the other fields are elements in the four transaction lines. Initially, the entry order is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 Suppose you wanted to change this order so that the user was required to enter data in the second field (Field_c) in each transaction line before the first field. To do this you would click once in Field_c on the first transaction line, and then again on Field_b. The change takes place after the two fields have been selected. The entry order would now be: 1 3 2 4 6 5 7 9 8 10 12 11 13 You might also want to ensure that data was entered in the transactions before Field_a. In this case you would need to select the Data Entry Order command again, and then click twice on Field_c in the first transaction. The entry order would then be: 13 2 1 3 5 4 6 8 7 9 11 10 12 Copying Fields Transactions may only be created by repeating fields with the Define Transaction Lines command. If you repeat a field from a transaction line using some other technique - by copying it or by adding it to the page a second time - it will only show the data for the current record and the current transaction line. Usually, this field would be marked as Read Only and would be used to display a full description of data which is truncated in the transaction line. Creating a Table Form If you define a form to show just a set of transaction lines from a single file - no one-to-many relationship - you can edit any of the visible transactions simply by clicking in it. A form like this will display multiple records from one file in a similar way to Sbase's Table View command. But it is has the advantage of allowing you to click on any of the lines on screen. The line then becomes the current record. You can use this feature for two purposes: as way of selecting a record from a list, and as a way of entering data into multiple records at the same time.