Article ID: 304473 - Last Review: March 29, 2007 - Revision: 8.1 How to edit records in related tables in a Microsoft Access database
This article was previously published under Q304473 Novice: Requires knowledge of the user interface on single-user
computers. This article applies to a Microsoft Access database (.mdb or .accdb) file. On This PageSUMMARY This article shows you how to edit records in related
tables. It includes the following topics:
MORE INFORMATIONHow to Add or Edit Data in a Datasheet (Table or Query) or in a Form
How to Save a Record in a Datasheet or in a FormMicrosoft Access automatically saves the record that you are adding or editing as soon as you move the insertion point to a different record or close the form or table that you are working on.In Access 2003 or in earlier versions of Access, to explicitly save the data in a record while you are editing it, click Save Record on the Records menu. In Access 2007, to explicitly save the data in a record while you are editing it, click the Home tab, and then click Save in the Records group. How to Delete a Record in a Datasheet or in a Form
How to Undo Changes Adding or Editing in a Datasheet or in a FormDo one of the following:
Referential IntegrityReferential integrity is a system of rules that Microsoft Access uses to ensure that relationships between records in related tables are valid, and that you do not accidentally delete or change related data. The following rules apply when you use referential integrity:
Cascade Updates and Cascade DeletesFor relationships in which referential integrity is enforced, you can specify whether you want Microsoft Access to automatically cascade update and cascade delete related records. If you set these options, delete and update operations that would normally be prevented by referential integrity rules are allowed. When you delete records or change primary key values in a primary table, Microsoft Access makes necessary changes to related tables to preserve referential integrity.If you click the Cascade Update Related Fields check box when you are defining a relationship, any time you change the primary key of a record in the primary table, Microsoft Access automatically updates the primary key to the new value in all related records. For example, if you change a customer's ID in the Customers table, the CustomerID field in the Orders table is automatically updated for every one of that customer's orders so that the relationship is not broken. Microsoft Access cascades updates without displaying any message. NOTE: If the primary key in the primary table is an AutoNumber field, setting the Cascade Update Related Fields check box will have no effect, because you cannot change the value in an AutoNumber field. If you select the Cascade Delete Related Records check box when you are defining a relationship, any time that you delete records in the primary table, Microsoft Access automatically deletes related records in the related table. For example, if you delete a customer record from the Customers table, all the customer's orders are automatically deleted from the Orders table (this includes records in the Order Details table related to the Orders records). When you delete records from a form or datasheet with the Cascade Delete Related Records check box selected, Microsoft Access warns you that related records may also be deleted. However, when you delete records using a delete query, Microsoft Access automatically deletes the records in related tables without displaying a warning. For more information about relationships, click the following article numbers to view the articles in the Microsoft Knowledge Base: 304466
(http://support.microsoft.com/kb/304466/
)
Defining relationships between tables in a Microsoft Access database
304469
(http://support.microsoft.com/kb/304469/
)
How to view and edit relationships in a Microsoft Access Database
About Restricting or Validating DataMicrosoft Access provides a variety of ways to control how a user enters data into a database. For example, you can limit the data that a user can enter into a field by defining a validation rule for that field. If the data that a user enters into the field breaks the rule, Access will display a message telling the user what kind of entries are allowed. Another method of controlling data entry is to create an input mask to restrict the kind of values that can be entered in positions across the field. You can perform these simple forms of validation and restriction by setting properties for fields in tables, or by setting properties for controls on forms.In most cases, it is preferable to define data validation and restriction by setting a field's properties in table Design view. That way, whenever you use that field in a form, the field's validation rule and other properties will apply to data entry performed by using the form. However, if the data entered into a control on a form is not bound to a field in a table, and you need to restrict or validate data entry, you must define those properties in the form. Additionally, there are situations where you must use macros or Microsoft Visual Basic for Applications code in conjunction with a form to perform more complex validation. For example, you might want to be able to override your validation rule or compare values from different tables. About SubdatasheetsIn a subdatasheet, you can view and edit related or joined data in a table, a query, or a form datasheet, or in a subform. For example, in the Northwind sample database, the Suppliers table has a one-to-many relationship with the Products table; so for each row of the Suppliers table in Datasheet view, you can view and edit the related rows of the Products table in a subdatasheet. Click the expand indicator to expand or collapse a subdatasheet.For more information about subdatasheets in Microsoft Access, visit the following Microsoft Web site: Access 2002 Online Help: About Subdatasheets
(http://office.microsoft.com/assistance/preview.aspx?AssetID=HP052362161033&CTT=4&Origin=CH063645611033)
When You Can Update Data from a QueryIn some cases, you can edit data in query Datasheet view to change the data in the underlying table. In other cases, you cannot. The following information shows whether a query's results can be updated, and if not, whether there is an alternative.Data is updatable:You can update a query or query field in the following cases:
Data is updatable under certain conditions:If a query is based on tables with a one-to-many relationship, you might not be able to edit the data for some query fields, or you might receive the following error message:Can't add record join
key of table tablename not in recordset. Collapse this table
Data can be deleted but not updated:Collapse this table
Data can't be updated:Collapse this table
REFERENCES For more information about relationships in an Access
database, visit the following Microsoft Web site: Access 2002 Online Help: About relationships in an Access database
(http://office.microsoft.com/en-us/assistance/HP052362161033.aspx)
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
