Testing Field and Table Validation Rules

You can experiment with entering table data and testing your validation rules at the same time. Testing database applications often requires much more time and effort than creating them. The following basic tests are required to confirm your validation rules:

  • Referential integrity. Type 25 in the EmployeeID field and 2 in the InitiatedBy field of the default blank record (number 10) and then press the up-arrow key. Pressing the up-arrow key tells Access that you're finished with the current record and to move up to the preceding record with the cursor in the same field. Access then tests the primary-key integrity before enabling you to leave the current record. If you haven't turned on the Office Assistant, the message box shown in Figure 6.11 appears; otherwise the Assistant delivers the message. Click OK and press Escape to abandon the entry.

    Figure 6.11. If you violate referential integrity rules by typing an EmployeeID value without a corresponding record in the Employees table, this message appears.

    graphics/06fig11.gif

  • No duplicates restriction for primary key. In the record just added, attempt to duplicate exactly the entries for record 9, and then press the up-arrow key. You see the message box shown in Figure 6.12, if you've turned off the Assistant. Click OK and press Escape to cancel the entry.

    Figure 6.12. If you duplicate the values of another record in the EmployeeID, ActionType, and ScheduledDate fields, you receive an error message because a primary key duplication occurs.

    graphics/06fig12.gif

  • ActionType validation. Type x and press the right-arrow key to display the message that appears if you added the lookup list and set the Limit To List property value to Yes (see Figure 6.13, top). Otherwise, the message box with the validation text you entered for the ActionType field appears (see Figure 6.13, bottom). Click OK and press Escape to abandon the entry.

    Figure 6.13. The error message for a lookup list with the Limit To List restriction set responds to an entry error with the upper message. If the Limit To List restriction is missing or you didn't add a lookup list, the Validation Text message appears.

    graphics/06fig13.gif

  • Employee ID validation in the InitiatedBy field. Type q and move to the InitiatedBy field. When the cursor leaves the ActionType field, the q changes to Q because of the > format character used. Type 0 (an invalid employee ID number), and press the right-arrow key to display the message box shown in Figure 6.14. Click OK or press Enter.

    Figure 6.14. Typing 0 in the InitiatedBy field violates the >0 Validation Rule and displays the Validation Text.

    graphics/06fig14.gif

Continue with the testing. Type a date, such as 1/31/2001, for the ScheduledDate, and type a date one day earlier (such as 1/30/2001) for the EffectiveDate to display the error message boxes with the validation text you entered. (You must move the cursor to a different record to cause the table-level validation rule to be applied.) Enter a valid date after the test. To edit a field, rather than retype it, press F2 to deselect the entire field and display the cursor for editing. F2 toggles selection and editing operations.

graphics/select_record.gif When you finish your testing, click the selection button of the last record you added, and then press Delete. The confirmation message shown in Figure 6.15 appears. You can turn off record deletion confirmation messages by clearing the Record Changes text box in the Confirm group of the Options dialog's Edit/Find page. Why this option group is located on the Edit/Find page is a mystery.

Figure 6.15. Unless you turn off confirmation of record deletion, this message appears when you delete a record.

graphics/06fig15.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