جاوا اسکریپت غیر فعال است برای تجربه بهتر، قبل از ادامه، جاوا اسکریپت را در مرورگر خود فعال کنید.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser .
آموزش کامل Access 2007-EN
[h=2]Building Table Relationships
[h=5]Relating Tables with the Drag and Drop Method
It is easy to relate tables from the relationship map:
Select a field name from one table by holding down the left mouse button.
Drag the field name from the one table to the other table in the desired relationship.
Drop the first field name onto the field name that you want to relate by releasing the left mouse button.
In the example above, we selected the Book ID field from the Books table, and dragged and dropped it on the Book ID field in the Orders table.
The
Edit Relationships dialog box appears.
Select the Enforce Referential Integrity option. This option is explained in detail below.
[h=2]Building Table Relationships
[h=5]Understanding Types of Relationships
Access 2007 allows for several different types of relationships. These include:
One to One
One to Many
Many to Many
The relationship type you will come across most frequently, and the one created in our bookstore scenario, is the
One to Many relationship.
[h=2]Building Table Relationships
One to Many
The
One to Many relationship means that data for that field will show up a single time in one table, but many times in the related table.
For example, let's look at one of the book titles in our bookstore. The Book ID for that book should appear
only once in the Books table, because that table lists every title that we stock. But it will probably
appear many times in the Orders table, because we hope that it gets ordered by many people many times.
The symbols for the
One to Many relationship look like this:
[h=2]Building Table Relationships
[h=5]Enforcing Referential Integrity
In the Edit Relationships dialog box, an option to Enforce Referential Integrity appears.
You should click Enforce Referential Integrity to make sure that we NEVER have an order for
a book that doesn't appear in our Books table. Selecting this option tells Access to check for
these things when someone is working with your data records.
[h=2]Building Table Relationships
[h=5]Editing Existing Relationships
Access 2007 allows you to edit relationships that already exist. This can be done using the Edit
R
elationships command on the Ribbon . However, a much simpler way is to simply double click
on the link that appears in the relationship map. Either method brings up the Edit Relationships
dialog box, where you can change your settings.
[h=2]Building Table Relationships
[h=3]Challenge!
If you haven't already done so, save the
sample Ready2Read database on your own computer.
Open the database and establish a relationship between the Books table and the Orders table using the Drag and Drop method.
Establish a relationship between the Customers table and the Orders table using the Edit Relationships command on the Ribbon .
Edit an established relationship by double-clicking the link.
Explore the options and settings in the Edit Relationships dialog box.
Move the tables around in the relationship map.
[h=2]Entering and Editing Data in Tables
[h=3]Introduction 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 and the
importance of setting
validation rules and other
field properties and to ensure that data is valid.
[h=2]Entering and Editing Data in Tables
[h=3]Adding and Editing Data in Tables
[h=5]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.
[h=2]Entering and Editing Data in Tables
To Add Records in the New Record Row:
Click the record row with the
asterisk that appears at the bottom of the table.
Type the data into the appropriate fields.
Hit Enter or the Tab key to move to the next field.
[h=2]Entering and Editing Data in Tables
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.
Type the data into the appropriate fields.
Hit Enter or the Tab key to move to the next field.
[h=2]Entering and Editing Data in Tables
To Add Records with the New Record Command :
Click the
New Record command in the Records group in the Ribbon.
Type the data into the appropriate fields.
Hit the Enter or the Tab key to move to the next field.
[h=2]Entering and Editing Data in Tables
[h=5]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.
[h=2]Entering and Editing Data in Tables
To Edit a Record Directly :
Scroll through the records or use the
Navigation Buttons in the navigation bar to find the record to edit.
Click the cell that contains the information that must be edited. A pencil icon appears to indicate edit mode.
Type the new information into the field.
Click outside of the record row to apply the change.
[h=2]Entering and Editing Data in Tables
To Edit a Record using Find and Replace :
Click the
Find command in the Find group on the Ribbon.
The
Find and Replace dialogue box opens.
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. Tip--The first choice in, the drop down is the field you were last in in 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 on 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.
Use Cancel to stop the edit process.
CAUTION : DO NOT use
Replace All , as it will overwrite every instance of the Find
term in the table, which can have a serious impact on your data.
[h=2]Entering and Editing Data in Tables
To Copy and Paste a Record :
Select the record that you want to copy. Right click and select Copy .
Select the new record row. Then right click and select Paste . The record information appears, with a new record ID number.
[h=2]Entering and Editing Data in Tables
To Delete a Record :
Select the record that you want to delete. Then, right click and select Delete Record .
A dialog box appears, telling you the action can not be undone and asking if you are sure you want to delete the record.
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.
When you delete a record, that 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.
[h=2]Entering and Editing Data in Tables
[h=3]Data Validation
Data Validation is a very 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.
Imagine that 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. Now, 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.
[h=2]Entering and Editing Data in Tables
[h=5]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.
Data validation is accomplished by setting
data validation rules and other
field properties for various fields.
[h=2]Entering and Editing Data in Tables
[h=5]Setting 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 rules work most easily with numeric fields. Rules for text fields require you to enclose each
acceptable value inside its own quotation marks, separating them with
Or , as seen above.
[h=2]Entering and Editing Data in Tables
[h=5]Validation Text
Validation Text is a specialized error message that you can set to have Access tell the person entering data the specific way you would like them to enter it.
To set the
Validation Text , enter the error message
exactly as you want it to appear to your user in
the row directly beneath the
Validation Rule row in the
Field Properties section of Design View. For
the validation rule that we set for Category, you would set the validation text like this:
The following image shows the resulting error message that the user would see when they have broken the Category validation rule: