Lesson 6: Entering and Editing Data in Tables

/en/access2007/building-table-relationships/content/

Introduction

Access 2007 Access 2007 databases hold the actual data records inside tables. You can add, edit, and delete records directly from these tables. This lesson will show you how to work in the tables to add new records, as well as how to edit existing records using commands like copy and paste and find and replace. It will also discuss the dangers involved in deleting records from a table, as well as the importance of setting validation rules and other field properties to ensure data is valid.

Adding and editing data in tables

Download the example to work along with the video.

Adding records to tables

When you enter records into your table, you are populating the database. In Access 2007, you can do this a few different ways.

To add records in the new record row:

  • Click the record row with the asterisk that appears at the bottom of the table.


    New Record RowNew Record Row

  • Type the data into the appropriate fields.
  • Hit Enter or the Tab key to move to the next field.

To add records with the New Record navigation button:

  • Click the New Record button in the navigation bar. The navigation bar is located in the bottom-left corner of the open object pane.

    New Record Navigation ButtonNew Record Navigation Button

  • Type data into the appropriate fields.
  • Hit Enter or the Tab key to move to the next field.

To add records with the New Record command:

  • Click the New Record command in the Records group in the Ribbon.

    New Record CommandNew Record Command

  • Type the data into the appropriate fields.
  • Hit the Enter or the Tab key to move to the next field.

Editing records in tables

Sometimes it is necessary to edit records in the database. Like with every other task in Access 2007, this can be done several different ways.

To edit a record directly:

  • Scroll through the records, or use the navigation buttons on the navigation bar to find the record to edit.

    Navigation ButtonsNavigation Buttons

  • Click the cell containing the information that must be edited. A pencil icon appears to indicate edit mode.

    Edit Record ModeEdit Record Mode

  • Type the new information into the field.
  • Click outside of the record row to apply the change.

To edit a record using Find and Replace:

  • Click the Find command in the Find group on the Ribbon.


    Find CommandFind Command

  • The Find and Replace dialog box opens.


    Find and Replace Dialog BoxFind and Replace Dialog Box

  • Tell Access what to find by typing it into the Find What: area.
  • Type the replace term in the Replace With: area.
  • Tell Access where to look with the Look In: drop-down list. The first choice in the drop-down list is the field you were last in within the table.
  • Tell Access what to Match: Any part of the field, the whole field, or just the start of the field.
  • Tell Access how to Search: Up finds records above the cursor, Down finds records below the cursor, and All searches all records.
  • Click one of the action options:
    • Find Next will find the next instance of the word in the table.
    • Replace will put the new word into the table, overwriting what is currently there.
    • Cancel stops the editing process.
CAUTION: DO NOT use Replace All because it will overwrite every instance of the Find term in the table, which can have a serious impact on your data.

To copy and paste a pecord:

  • Select the record you want to copy. Right-click, then select Copy.
  • Select the new record row. Right-click and select Paste. The record information appears with a new record ID number.

To delete a record:

  • Select the record you want to delete, then right-click and select Delete Record.
  • A dialog box appears, telling you the action cannot be undone and asking if you are sure you want to delete the record.

Delete Record Dialog BoxDelete Record Dialog Box

There may be other records that rely on the record you are trying to delete. DO NOT delete a record without knowing how it will impact the rest of your database.

Record NumbersRecord Numbering after Deleting Records

When you delete a record, the record number is permanently deleted from the database table. If you delete the last record from a table and then add a new record, your new record numbers will appear to be out of sequence.

Data validation

Data validation is an important database concept. It is the process by which Access tests the data that is being entered into the database to make sure it is in an acceptable—or valid—format.

Let's say one of your database users has entered an order date of January 4, 2008, in the month/date/year format as 01/04/2008. Another user has entered an order placed on that same date in the day/month/year format as 04/01/2008. If the database is tracking all sales for the month of January 2008, it may not show both orders as placed in January, even though both were placed on the same date.

Access 2007 allows you to set field properties and data validation rules to force the person entering data to follow a specific format.

Data types and validation rules

Data validation begins when data types are set during the process of building tables and fields. For example, if a field data type had been set to Currency and a text value is entered in that table field during data entry, Access will not accept an invalid format and will display a validation error, like the one below.

Mismatched DataData Validation Error Message

Data validation is accomplished by setting data validation rules and other field properties for various fields.

To set data validation rules:

  • In Design view, highlight the field that requires a validation rule.
  • In the Field Properties section at the bottom half of the window, set your validation rule using the Expression Builder. The Expression Builder offers common syntax to set up a data validation rule.

    Validation RulesUse Expression Builder to Enter Validation Rule


    Category Validation RuleValidation Rule for Category Field

Validation rules work most easily with numerical fields. Rules for text fields require you to enclose each acceptable value inside its own quotation marks, separating them with Or, as seen above.

Validation text

Validation text is a specialized error message you can set to have Access tell the user entering data the specific way you want that person to enter it.

To set the validation text, enter the error message exactly as you want it to appear to users in the row directly beneath the Validation Rule row in the Field Properties section of Design view. For the validation rule we set for Category, you'd set the validation text like this:

Category Validation TextValidation Text for Category Field

The image below shows the resulting error message users would see when the Category validation rule has been broken.

Error Message for Category RuleError Message Showing Validation Text

Using field properties to ensure data integrity

Another way to ensure data integrity is by setting field properties such as Field Size, Format, and Required.

  • Field Size can be set to hold a specific number of characters, up to as many as 255 for text fields. If you were using a text field to hold the two-letter state postal abbreviation, the field size could be set to 2 to ensure no one enters a full state name into this field.
  • The Format field property can be set to display text or numbers in a standardized way. For example, text can be set to show as all uppercase, and numbers can be set to show scientific numbers, percentages, or decimals.
  • Set the Required property to Yes if you want users entering data to be required to enter something in the field. Choose No if users are allowed to leave the field blank.

These are just some ways Access helps you ensure data being entered into your database is valid.

Challenge!

If you haven't already done so, save the sample Ready2Read database to your computer.

  • Open the database, and add records using the New Record navigation button.
  • Add a record using the New Record command in the Ribbon.
  • Edit a record using the Find and Replace command.
  • Copy and paste a record in one of the tables.
  • Set a validation rule and validation text for a field in one of your tables, then break the rule when entering data to read the resulting message.

/en/access2007/creating-and-using-forms/content/