Using Transaction-Processing Forms

As noted near the beginning of this chapter, the purpose of transaction-processing forms is to add new records to, delete records from, or edit data in one or more tables that underlie the form. The sections that follow describe how to add new records to the HRActions table with the frmHRActions form.

Toolbar Buttons in Form View

The toolbar buttons of Form view are the same as those for tables in Datasheet view. For example, the Find button serves the same purpose for forms in Run mode as it does for tables and queries. You type characters in the Find dialog using wildcards if needed. When you execute the search, Access displays the first record that matches your entry if a match is found.

The Sort Ascending, Sort Descending, Filter by Selection, and Filter by Form buttons work the same way in Form view as they do in Datasheet view. Using these filter buttons is described in Chapter 7, "Sorting, Finding, and Filtering Data." Sorting specified in the form overrides the sort criteria of the primary query used as the source of the data (if your form is based on a query, rather than directly on one or more tables). The filter or sort criteria you specify don't take effect until you click the Apply Filter/Sort button or make the equivalent Records, Apply Filter/Sort menu choice.

Note

graphics/delete_record.gif

graphics/new_record.gif Some toolbar buttons are disabled as a result of your form design or its property values. For example, the Delete Record button is disabled when the frmHRActions form is open because you've set the Allow Deletions property value to No for the both form and subform. The Add Record button is disabled when you select the main form and enabled when you select the subform.


Using the HRActions Form

graphics/previous_page.gif graphics/next_page.gif Forms you create with the Form Wizard use the standard record-navigation buttons located at the bottom of the form. The record-navigation buttons perform the same functions with forms as they do with tables and queries. You can select the first or last records in the table or query that is the source of data for your main form, or you can select the next or previous record. Subforms include their own set of record-selection buttons that operate independently of the set for the main form.

Note

graphics/power_tools.gif

If you didn't create the frmHRActions form in the preceding sections of this chapter, the form, subform, and HRActions table are included in the Forms14.mdb database in your \Program Files\Seua11\Chaptr14 folder.


Navigation between the text boxes used for entering or editing data in the form is similar to navigation in queries and tables in Datasheet view except that the up-arrow and down-arrow keys cause the cursor to move between fields rather than between records. Accept the values you've entered by pressing Enter or Tab.

Appending New Records to the HRActions Table

graphics/new_calls_record.gif In Datasheet view of a table or query, the last record in the datasheet is provided as a tentative append record (indicated by an asterisk on the record-selection button). If you enter data in this record, the data automatically is appended to the table and Access starts a new tentative append record. Forms also provide a tentative append record, unless you set the Allow Additions property value for the form to No.

The following comments apply to adding HRAction records with the frmHRActions form:

  • Because data from the Employees table is included in the main form, the ID number, name, and title of the employee appear in the text boxes on the main form. Your form design lets you edit the LastName, FirstName, and Title data, although these fields are incorporated in the table (Employees) on the one side of a one-to-many relationship. The editing capability of a form is the same as that for the underlying table or query that serves as its source unless you change the form's editing capabilities by setting the form's Allow Editing property and other related properties.

  • After you add a new record to the HRActions table, you can't delete or edit it, because the Allow Edits and Allow Deletions property values are set to No.

    Tip

    When experimenting with adding records to the HRActions table, temporarily set the subform's Allow Edits and Allow Deletions property values to Yes.


  • If you added an entry for the chosen employee ID when you created the HRActions table in Chapter 5, the entry appears in the subform's fields. The subform's data display is linked to the data in the main form through the one-to-many relationship between the Employees table and the HRActions table. The subform only displays records from the HRActions table whose EmployeeID fields match the value of the EmployeeID field of the record currently displayed by the main form.

To append a new record to the HRActions table and enter the required data, follow these steps:

  1. graphics/subform.gif Open the frmHRActions form if it isn't already open or click the Form View button if you're in Design view. Data for the first record of the Employees table with the matching data from the corresponding record(s) in the HRActions table appears in the text-box controls of your form.

  2. graphics/find.gif Access places the cursor in the first text box of the main form, the ID text box. The first example uses Steven Buchanan, whose employee ID is 5, so do the following: Click the Find button on the toolbar to open the Find dialog, type 5 in the Find What text box, make sure that the Look In control is set to ID, and click Find First. Access displays the Employees table data for Steven Buchanan in the main form and his HRActions records in the subform. Click Cancel to close the Find dialog.

    Note

    graphics/new_calls_record.gif

    Alternatively, click the Next Record button of the lower set of navigation buttons four times to open the record for Mr. Buchanan.

    Tip

    If you change the value of the AutoNumber ID field, for instance to 5, you receive a "Field can't be updated" message when you move the cursor to another field. Press Esc to cancel the change. (Typing the original value generates the same message.)

    You can prevent editing of this or any other field of a form or subform by changing the Locked property of the field's text box to Yes.

  3. graphics/tentative_append_record.gif Click in the Type field of the tentative append record in the subform. If the tentative append record in the subform isn't visible, click in any field in the subform and then click the New Record button on the toolbar to move to the tentative append record at the end of the existing HRActions table entries for Steven Buchanan.

  4. Type a valid HRAction type (H, Q, Y, S, R, B, C, or T because of the field's validation rule) in the Type text box. (If you added the lookup list to the Action field, you can select the type code from the list.) Default date values appear in the Scheduled and Effective fields. In this example, you bring Steven Buchanan's HRActions records up-to-date by adding quarterly performance review information. Press Tab or Enter to accept the default Type value and move the cursor to the next data-entry text box, Initiated By.

  5. Mr. Buchanan reports to the vice president of sales, Andrew Fuller, whose employee ID is 2. Type 2 in the Initiated By text box and press Enter.

    Note

    graphics/pencil_symbol.gif

    The pencil symbol, which indicates that you're editing a record, replaces the triangle at the top of the Record Selector bar to the left of the record that you are entering. The Description property you entered for the field in the table underlying this query appears in the status bar and changes as you move the cursor to the next field. (To change a previous entry, press Shift+Tab, or use the up- and down-arrow keys to maneuver to whichever text box contains a value you want to change.)

  6. Mr. Buchanan was hired on 10/17/1993, but Northwind Traders had no human resources (HR) department to maintain HR data until mid-1998, so type 10/17/1998 in the Scheduled field.

  7. Because Mr. Fuller is a vice-president, he has the authority to approve salary increases. Type Mr. Fuller's employee ID, 2, in the Approved By text box and then press Enter to move the cursor to the next field.

  8. The effective date for salary adjustments for Northwind Traders is the 1st or 15th day of the month in which the performance review is scheduled. Type the appropriate date in the Effective text box.

  9. You can type any number from 0(terminated) to 9(excellent) in the Rating text box, which reflects the employee's performance.

  10. You can be as generous as you want with the salary increase that you enter in the Salary text box. The value of the Salary field is a new monthly salary, not an incremental value.

  11. In the Comments multiline text box to the right of the New Amount field, add any comments you care to make concerning how generous or stingy you were with this salary increase. The multiline text box includes a scroll bar that appears when the cursor is within the text box.

  12. graphics/tentative_append_record.gif When you complete your entries, Access stores them in a memory buffer but doesn't add the new record to the HRActions table. You can add the record to the table by choosing Records, Save Record; clicking the New Record button; or changing the position of the record pointer with the Previous or Next record selector button. If you want to cancel the addition of a record, press Esc twice.

  13. Repeat steps 3 through 12 to add a few additional records.

Tip

graphics/tentative_append_record.gif

graphics/previous_page.gif If you click the New Record button on the toolbar (or the Next Record selector button) to select the tentative append record, and then decide that you don't want to add any more data, click the Previous Record button to make sure this new record is not added to the table. If the table has required fields without default values, however, you must enter a value for each required field, and then delete the added record. Deleting records requires setting the subform's Allow Deletions property value to Yes.


When adding a record, your form appears like the one shown in Figure 14.24. Each record for an employee appears in the subform datasheet in the order of the primary key fields of the HRActions table.

Figure 14.24. The frmHRActions form appears as shown here after appending a new subform record for an employee.

graphics/14fig24.gif



Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net