"SBase Personal - 6. ENTERING DATA" 6 ENTERING DATA Entering New Records in Page or Record View Entering Text All Fields or Selected Fields? Entering New Records in a Form Editing Existing Data Selecting Another Record Editing Controls Field Selection with the Mouse Page and Record View Field Markers Moving from Field to Field Editing within a Field Undo Editing Entering Dates Entering Times Entering Numbers Required Fields Read Only Fields Validated Fields Calculation Fields Constant Fields Creating Duplicate Records The Clipboard Field Level Cut, Copy and Paste Cut Copy Paste Pasting Multiple Records 6 ENTERING DATA You may enter and edit data through either a form or the Page or Record default views. This chapter covers both situations. Page and Record View operate on one file at a time, whereas forms may include fields from many files, and can update all of them with a single Save command. There are three ways of entering data into a file: interactively using the Record and Edit menus, from the Clipboard, or through a batch import. In this chapter we deal with the first two methods. See Chapter 21 Import for information on importing data from another file. Entering New Records in Page or Record View Each record in a file has the same format, as set out in the file definition, consisting of a number of fields of different types. If it helps, you can imagine each record as a card in a card index, or a form in a folder. When you want to create a new record (`add a card to the box,' or `add a form to the folder'), you have to follow a simple procedure: 1. In the Project menu, point to Open and File, then select the required file. 2. In the Record menu, point to New (or press AMIGA+N). SBase 4 presents a blank record with the insertion point in the first editable field. A blank record for the example Clients file would look like this *** See Fig 6-1 *** - If there are any constant fields, their initial values are displayed. 3. Type in the data for the first field, pressing ENTER to finish. - You can exit from data entry at any time by pressing ESCAPE. - You can save a record at any time with the AMIGA+S shortcut provided the insertion point is not active. - You must use TAB to exit from a text field that allows Returns. See below. 4. Repeat step 3 for each field. - After you press ENTER in the last field, SBase 4 asks you whether you want to save the record (add it to the file). 5. Press ENTER to save the record, or ESCAPE to stop. - Whenever you save a record SBase 4 presents you with a blank record so that you can create another. Press ESCAPE if you do not want to create another record. If you want to duplicate an existing record, display it then point to Duplicate in the Record menu. If you make mistakes while typing in data, you can correct them using the Backspace and Delete keys together with the other editing controls explained below. If you have set up validation formulas in the file definition, these are performed as you enter data. Required fields may not be left blank. Unique index key entries are checked when you press ENTER in the key field. You may leave an index field blank - SBase makes an entry of spaces in the index, and the record will appear first in sorting order. Remember that if the index only allows unique entries it will not let you store more than one record with a blank unique index field. Entering Text When you edit a text field whose entire length is not displayed, SBase 4 creates a multi-line editing box. You can use the normal editing controls to move the insertion point within the field. If the field is able to include Returns, as specified in the Text Format requester, you can press ENTER inside it to end paragraphs and create blank lines. To exit from such a field, you must press TAB or SHIFT+TAB. All Fields or Selected Fields? The field names that appear may be all the fields or just a few of them. This depends on whether there is a selected fields list active. If you want to enter data into just a few of the fields in the record you should open only those fields using the Field Selection command on the Set menu. If you do use a selected fields list, SBase 4 still processes the fields that do not have data entered into them. If a field fails a validation check because you've left it empty, SBase 4 will tell you. Entering New Records in a Form The steps for starting data entry with a form are almost exactly the same as for a file. 1. Open the form - in the Project menu, point to Open and Form. - The act of opening the form opens all the files needed for the form automatically. 2. Select Record New (AMIGA+N). SBase 4 presents a blank form with the insertion point in the first editable field. A blank form might typically appear like this. *** See Fig 6-2 *** - If there are any constant fields, their initial values are displayed. 3. Type in the data for the first field, pressing ENTER to finish. - You can exit from data entry at any time by pressing ESCAPE. 4. Repeat step 3 for each field. - After you press ENTER in the last field, SBase 4 asks whether you want to save the form. 5. Press ENTER to save the form data, or ESCAPE to stop. - If you press ESCAPE to stop, you can go back and make changes and then save the form data with the Save command on the Record menu (AMIGA+S). - If you press ENTER to save, SBase 4 asks whether you want to continue. 6. Press ENTER to start again with a blank form, or ESCAPE to stop. Saving Form Data When you save form data with the Record Save command, and fields from more than one file are on the form, SBase 4 works out which files require updating. If a record from a file has been looked up just so that a field from it may be displayed, but the data for that record has not been changed at all, SBase 4 does not create a new record for that file. The best way to ensure that looked up data is not changed is to make all the fields that come from that file Read Only on the form itself, even if they are not Read Only in the file definition. On a multi-file form, all the files are linked through pairs of common reference fields. Only one of the pair actually needs to be on the form. SBase 4 gives the other one the same value when the data is saved, so that the related records may be retrieved together. See Chapter 17 Multi-File Applications, for more information on data entry in a multi-file situation. Editing Existing Data In Page or Record View, or when using a form, you can start editing at any time just by clicking in any field. You can use the scroll bars to bring any part of the record or form into view. You can only edit the current record or form data. So you must first select the data you wish to edit. You can do this in one of three ways: - Browsing with a form open. - Browsing in Record or Page View. - Browsing in Table View, using the Current Record button to confirm that you have the right record. - Direct retrieval with the Key Lookup button. Once you have selected the record you want you can start editing. 1. Click in the field that you want to change, or: Select the Current command on the Edit menu (AMIGA+E). - If Table View is set, SBase 4 switches to Page View. The insertion point appears in the first field on the screen that is not protected by being defined as Read Only. 2. When you have finished making changes, save the record with the Save command on the Record menu (AMIGA+S). Selecting Another Record If you have made any changes to the current record or form data, or added any data to a new record, SBase 4 does not let you perform any other action that involves selecting a record without asking whether you want to go ahead and save first. Editing Controls A set of editing controls allows you to enter and edit data quickly and easily. Field Selection with the Mouse 1. Move the pointer over the field you want. 2. Click the mouse. If you click inside the field, SBase 4 produces an insertion point at the character on which you click, unless the field is on a form and its data is displayed in a non-system font. If the field is shown in a non-system font, the insertion point will appear where you click, but since SBase 4 has to change the field contents into the system font for you to edit it, the insertion point may not be on the actual character you clicked. It is easy to click again, or just use the direction keys to move to the desired place. In Record View, if you click beyond the end of the field, SBase 4 moves the insertion point to the end of the existing data; if you click before the start of the field, SBase 4 moves the insertion point to the start of the field. Page and Record View Field Markers In these two views each field starts one space after the end of the field name zone. In Record View the end of the field that the insertion point is in is marked by a vertical bar. If the field names are shown, all fields in Page View have end of field markers. Moving from Field to Field You may edit any field simply by moving the mouse and clicking. - In Page View, the UP and DOWN direction keys move the insertion point to the next field above or below the current field (the exact move depends on the position of the insertion point in the field and whether the field names begin in the same column). In Record View, UP and DOWN moves up or down a field respectively. - ENTER moves the insertion point to the next field. CTRL+ENTER moves the insertion point to the previous field. - In forms, the data entry order may be defined by the user, so pressing ENTER or DOWN simply moves the insertion point to the next field in the order. Pressing CTRL+ENTER or UP moves the insertion point to the previous field. Editing within a Field Editing Activity Key Combination Move insertion point LEFT and RIGHT direction keys Beginning of field SHIFT+LEFT End of field SHIFT+RIGHT Exit from editing ESCAPE Insert or Typeover CTRL+V Delete character DEL Delete character left BACKSPACE Clear field CTRL+X - Provided that NUM LOCK is switched off (which you can do with the Set System Options command), HOME positions the insertion point at the beginning of the field, END positions it at the end of the field, and INS switches between Insert and Typeover modes. Undo Editing Undo field edits CTRL+U only possible while the insertion point is still in the field and changes have not been saved) Undo record edits ESCAPE Reselect the current record UP direction key only possible while the changes have not been saved) Entering Dates For a date field, SBase 4 uses the format specified for the field in the File Definition as the basis for display. This allows useful short cuts like entering `6 9 89' and having it displayed as `June 9, 1989'. The only requirement is that you get the Day Month Year order right. A date in a Validation Formula must conform to the Day Month Year order in the format for the system date as specified with the Date Format command in the Set menu. Entering Times Times must be entered in the format specified in the File Definition. Entering Numbers As with dates, SBase 4 uses the format specified for a numeric field in the File Definition as the basis for display. SBase 4 is very tolerant of spaces in your editing. You can enter, for example, `2300.5' and have it neatly redisplayed as `$ 2,300.50'. Required Fields If a field has Required status, you must enter some data into it. If you press ENTER in an empty required field, SBase 4 displays an error message. Read Only Fields You cannot enter data into a Read Only field. If you attempt to do so, SBase 4 will move the insertion point on to another field. Validated Fields If you have specified a validation check for a field, any data you enter must pass the check. If it does not, you will see a message like this: *** See Fig 6-3 *** If you already know what the Validation Formula is, then click on the OK button of the message requester. This allows you to continue editing the field. If you can't remember what the rules for the field are, click on the Cancel button on the requester. Now select Status File from the Utilities menu. This will show you the Validation Formula for the field you are editing. When you understand the rules governing entry into the field, select Current from the Edit menu, click Cancel to retain the incomplete record data, and continue editing. You may want to be able to skip over a field that has a validation check attached. If so, you must include a zero or null option in the Validation formula when you specify it. See Chapter 7 Data Entry Validation. Validation is only performed when field contents change. If you enter data that fails a validation check and then click Cancel when the error requester appears, the failed data is allowed to remain in the field while you continue working. Simply pressing ENTER in the field does not cause SBase 4 to register a change. However, SBase 4 does not allow you to save invalid data, so the error message will re-appear when you select the Record Save command. Calculation Fields Fields that have calculation formulas attached to them will generally be Read Only fields. This means they cannot be edited directly. If they are not Read Only, you will be able to enter data in the field but it will be overwritten when the calculation is performed - unless it is a self-referencing calculation (see Chapter 8 Derived Values). When you are entering data into a new record or editing an existing one, SBase 4 does not display the results of a calculation formula until you: - Click on the calculated field, or - Pass through the field, or - Go to save the record Constant Fields Fields with constant formulas attached to them cannot be edited directly if they are Read Only fields. Otherwise, you can edit these fields in the usual way. Remember that SBase 4 only works out the result of a constant formula when the record is first created. Thereafter the formula becomes inoperative. Any data you enter will therefore overwrite the result of the formula. Creating Duplicate Records The Record Duplicate command allows you to cut down on the time taken to enter records where some of the data is the same. You make a `snapshot' of the current record in memory, edit in any changes you want, and then save it in the normal way. 1. Select the record to be duplicated. 2. Select the Record Duplicate command (AMIGA+D). - SBase 4 shows a message to confirm that a snapshot record is ready for editing. 3. Make any changes required. 4. Save the record (AMIGA+S). Record Duplicate re-initializes any constant formulas. This means you can duplicate a record which contains the constant formula SER without duplicating its serial number. Similarly, if a file uses the constant formula TODAY, creating a new record by duplicating an existing record does not reproduce the original date. The Clipboard The clipboard is a temporary storage area. Because it is common to all standard Workbench applications, you can use it to transfer data between different programs. The standard commands for transferring data to and from the clipboard are Cut, Copy and Paste. If you cut or copy data using another program, you can then switch to SBase 4 and paste the same data into a SBase 4 file. And the process also works the other way round: other programs can make use of SBase 4 data which has been placed on the clipboard. Within SBase 4, the clipboard also serves as a trash can allowing you to remove data permanently. It is important to understand that the clipboard can only hold one set of data at a time. If you cut or copy a record or a field, it will overwrite any data that is already stored in the clipboard. Pasting data, on the other hand, leaves the clipboard intact. You can paste the same set of data as many times as you wish. With a multi-file form, only data from the current file is placed on the clipboard. You may have to select each file in turn if you wish to remove all the data that appears on a form. Note Some applications can store both text and graphics on the clipboard; SBase 4 only stores text. Note also that when you Cut or Copy records to the clipboard, fields are stored on one line separated by tab characters (eight spaces). Field Level Cut, Copy and Paste At field level, the Cut, Copy and Paste commands operate only on the whole field. A copy of the data in the selected field may be placed on the clipboard by Cut (AMIGA+X) and Copy (AMIGA+C), and removed from the field by Cut. Paste (AMIGA+V) reads data into the field from the clipboard. You may use this facility when you are creating new records which contain the same data in one of their fields. First copy the field data to the clipboard, then paste it into the same field in each of the new records. Another use is in conjunction with the SBase 4 Text Editor. Data can be written to the clipboard from within the Text Editor, and then pasted into individual fields in database records. Cut From time to time you may find that a record is no longer needed. Provided the insertion point is not active, this menu command removes the current record and stores it on the clipboard. 1. Make sure that the insertion point is not present (press ESCAPE if necessary). 2. Select the record you want to remove. 3. Select Cut from the Edit Menu or press AMIGA+X. If you discover that you have made a mistake and have removed the wrong record, you can restore it using the Paste command - provided you have not used Cut or Copy with another record in the intervening period. Copy Use this command if you want to place an exact copy of the current record on the clipboard. 1. Make sure that the insertion point is not present (press ESCAPE if necessary). 2. Select the record you want to copy. 3. Select Copy from the Edit Menu or press AMIGA+C. Before copying a record, make sure that the insertion point is not active. Then select Copy from the menu or press AMIGA+C. Paste Paste reads the contents of the clipboard into the database file. If there is an insertion point in a field, the data is pasted into that field. When there is no insertion point in any field, Paste takes the data on the clipboard and inserts it in the current file. If you have previously cut or copied a record from another file, selecting Paste from the menu (or pressing AMIGA+V) will store it as a new record in the current file. - You do not need to save the record after using Paste. Pasting Multiple Records It is possible for the clipboard to contain data for more than one record; this could occur, for example, if you cut or copied rows from a Workbench spreadsheet. In this case, Paste will create multiple records in the current file. SBase 4 shows a requester to indicate how many records have been pasted into the file. - The clipboard data must be in the correct format for the current file. For example, dates and numbers must be valid. See also Chapter 23 Editing Text.