Unlike Chapter 14's frmHRActions form, the Record Source for the main frmHrActionEntry form is a query. The query design takes advantage of Access' row fix-up feature when you add a new record to the HRActions table in the form. Row fix-up works in this case, because the source of the qryHRActions query's EmployeeID column is the HRActions table.
For a review of row fix-up in one-to-many queries, see "Taking Advantage of Access's Row Fix-Up Feature," p. 431. To add a new record to the HRActions table, do the following:
At this point in its development, frmHRActionEntry would be dangerous to release for use by data entry operators. For example, all fields in the main form are updatable. Thus, an operator could change the FirstName, LastName, and other values of the Employees table, as well as the EmployeeID for an existing HRActions record. You can set the Locked property to Yes for all controls linked to the Employees table, but you can't lock the EmployeeID text box that's required to specify the EmployeeID of a new record. You can control the locked status of form controls by adding VBA event-handling code for the form's Before Insert and After Insert events. Tip You can make frmHRActionEntry safe for data entry operators by setting the Data Entry property of the form to Yes. Specifying Data Entry prevents operators from viewing existing records and only allows them to enter new records. In this case, you must change the Recordset Type property value of the subform to Dynaset, and set the AllowEdits, AllowDeletions, and AllowAdditions property values to Yes. Otherwise, the added record won't appear in the History subform. |