Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
You can bring the data from a Microsoft Office Excel 2007 workbook into Microsoft Office
Access 2007 in many ways. You can copy data from an open worksheet and paste it into an
Access datasheet, import a worksheet into a new or existing table, or link to a worksheet from an
Access database.
This topic explains in detail how to import or link to Excel data from Access.
You are a long-time user of Excel but, going forward, you want to use Access to work
with this data. You want to move the data in your Excel worksheets into one or more new
Access databases.
Your department or workgroup uses Access, but you occasionally receive data in Excel
format that must be merged with your Access databases. You want to import these Excel
worksheets into your database as you receive them.
You use Access to manage your data, but the weekly reports you receive from the rest of
your team are Excel workbooks. You would like to streamline the import process to
ensure that data is imported every week at a specific time into your database.
If this is the first time you are importing data from Excel
There is no way to save an Excel workbook as an Access database. Excel does not
provide functionality to create an Access database from Excel data.
When you open an Excel workbook in Access (in the File Open dialog box, change the
Files of Type list box to Microsoft Office Excel Files and select the file you want),
Access creates a link to the workbook instead of importing its data. Linking to a
workbook is fundamentally different from importing a worksheet into a database. For
more information about linking, see the section Link to data in Excel, later in this article.
Top of Page
1. Locate the source file and select the worksheet that contains the data you want to import
to Access. If you want to import only a portion of a worksheet, you can define a named
range that includes only the cells that you want to import.
a. Switch to Excel and open the worksheet that you want to import.
b. Select the range of cells that contain the data that you want to import.
c. Right-click within the selected range and then click Name a Range.
d. In the New Name dialog box, specify a name for the range in the Name box and
click OK.
Remember that you can import only one worksheet at a time during an import operation.
To import data from multiple worksheets, repeat the import operation for each worksheet.
2. Review the source data and take action as described in this table.
Element Description
Number of The number of source columns that you want to import cannot exceed 255, because
columns Access does not support more than 255 fields in a table.
Skipping It is a good practice to include only the rows and columns that you want to import
columns and in the source worksheet or named range.
rows
Rows You cannot filter or skip rows during the import operation.
Columns You cannot skip columns during the operation if you choose to add the
Element Description
Also, it is a good practice to format each source column in Excel and assign a
specific data format to each column before you start the import operation.
Formatting is highly recommended if a column includes values of different data
types. For example, the FlightNo column in a worksheet might contain numeric
and text values, such as 871, AA90, and 171. To avoid missing or incorrect values,
Data type
do the following:
If the source columns are formatted, but still contain mixed values in the rows
following the eighth row, the import operation might still skip values or convert
values incorrectly. For troubleshooting information, see the section Troubleshoot
missing or incorrect values.
First row If the first row in the worksheet or named range contains the names of the columns,
you can specify that Access treat the data in the first row as field names during the
import operation. If your source worksheet or range doesn't include the names, it is
a good idea to add them to the source before you start the import operation.
Note: If you plan to append the data to an existing table, ensure that the name of
each column exactly matches the name of the corresponding field. If the name of a
Element Description
column is different from the name of the corresponding field in the table, the
import operation will fail. To see the names of the fields, open the table in Design
view in Access.
1. Close the source workbook, if it is open. Keeping the source file open might result in data
conversion errors during the import operation.
1. Open the Access database where the imported data will be stored. Ensure that the
database is not read-only, and that you have permissions to make changes to the database.
-or-
If you don't want to store the data in any of your existing databases, create a blank
database. To do so:
2. Before you start the import operation, decide whether you want to store the data in a new
or existing table.
Create a new table If you choose to store the data in a new table, Access creates a
table and adds the imported data to this table. If a table with the specified name already
exists, Access overwrites the contents of the table with the imported data.
Append to an existing table If you choose to add the data to an existing table, the rows
in the Excel file are appended to the specified table.
Remember that most failures during append operations occur because the source data
does not match the structure and field settings of the destination table. To avoid this, open
the destination table in Design view and review the following:
o First row If the first row of the source worksheet or named range does not
contain column headings, ensure that the position and data type of each column in
the source worksheet matches those of the corresponding field in the table. If the
first row contains column headings, the order of columns and fields do not need to
match, but the name and data type of each column must exactly match those of its
corresponding field.
o Missing or extra fields If one or more fields in the source worksheet do not
exist in the destination table, add them before you start the import operation.
However, if the table contains fields that don't exist in the source, you do not need
to delete those fields from the table if they accept null values.
Tip: A field will accept null values if its Required property is set to No and its
ValidationRule property setting doesn't prevent null values.
o Primary key If the table contains a primary key field, the source worksheet or
range must have a column that contains values that are compatible with the
primary key field, and the imported key values must be unique. If an imported
record contains a primary key value that already exists in the destination table, the
import operation displays an error message.
o Indexed fields If the Indexed property of a field in the table is set to Yes (No
Duplicates), the corresponding column in the source worksheet or range must
contain unique values.
1. In the Get External Data - Excel Spreadsheet dialog box, in the File name box, specify
the name of the Excel file that contains the data that you want to import.
-or-
Click Browse and use the File Open dialog box to locate the file that you want to import.
To store the data in a new table, select Import the source data into a new table in the
current database. You will be prompted to name this table later.
To append the data to an existing table, select Append a copy of the records to the
table and select a table from the drop-down list. This option is not available if the
database does not contain any tables.
Note: To link to the data source by creating a linked table, see the section Link to data in
Excel, later in this article.
3. Click OK.
The Import Spreadsheet Wizard starts, and leads you through the import process. Go to
the next set of steps.
1. On the first page of the wizard, select the worksheet that contains the data that you want
to import, and then click Next.
2. On the second page of the wizard, click either Show Worksheets or Show Named
Ranges, select either the worksheet or the named range that you want to import, and then
click Next.
3. If the first row of the source worksheet or range contains the field names, select First
Row Contains Column Headings and click Next.
If you are importing the data into a new table, Access uses these column headings to
name the fields in the table. You can change these names either during or after the import
operation. If you are appending the data to an existing table, ensure that the column
headings in the source worksheet exactly match the names of the fields in the destination
table.
If you are appending data to an existing table, skip directly to step 6. If you are adding the
data to a new table, follow the remaining steps.
4. The wizard prompts you to review the field properties. Click a column in the lower half
of the page to display the corresponding field's properties. Optionally, do any of the
following:
o Review and change, if you want, the name and data type of the destination field.
Access reviews the first eight rows in each column to suggest the data type for the
corresponding field. If the column in the worksheet contains different types of
values, such as text and numbers, in the first eight rows of a column, the wizard
suggests a data type that is compatible with all of the values in the column —
most often, the text data type. Although you can choose a different data type,
remember that values that are not compatible with the data type you choose will
be either ignored or converted incorrectly during the import process. For more
information about how to correct missing or incorrect values, see the section
Troubleshoot missing or incorrect values, later in this article.
If Access was able to import some or all of the data, the wizard displays a page that
shows you the status of the import operation. In addition, you can save the details of the
operation for future use as a specification. Conversely, if the operation completely failed,
Access displays the error message An error occurred trying to import file.
7. Click Yes to save the details of the operation for future use. Saving the details helps you
repeat the operation at a later time without having to step through the wizard each time.
1. In the Save as box, type a name for the import specification. Optionally, type a
description in the Description box.
2. If you want to perform the operation at fixed intervals, such as weekly or monthly, select
the Create Outlook Task check box. This creates an Microsoft Office Outlook 2007 task
that lets you run the specification at a later date.
3. Click Save Import.
Note: If Outlook is not installed, Access displays an error message. If Outlook is not
configured properly, the Outlook Startup wizard starts. Follow the instructions in the
wizard to configure Outlook.
4. In Outlook, review and modify the task settings, such as Due date and Reminder.
To make the task recur, click Recurrence. This figure shows the task scheduler with
some typical settings:
For information about scheduling Outlook tasks, see the article Schedule an import or
export operation.
1. In the Outlook Navigation Pane, click Tasks, and then double-click the task that you
want to run.
2. On the Task tab, in the Microsoft Office Access group, click Run Import .
3. Open the destination table in Datasheet view. Compare the data in the table with the
source worksheet, and ensure that the data appears to be correct.
If you find that some data is either missing or incorrect, see the next section for
troubleshooting information.
Top of Page
It is important to note that even if the status message indicates a completely successful operation,
you should review the contents and structure of the table to ensure that everything looks correct
before you start using the table.
Open the destination table in Datasheet view to see if all data was added to the table. In addition,
open the table in Design view to review the data type and other property settings of the fields.
The following table describes the steps you can take to correct missing or incorrect values.
Tip: While you are troubleshooting the results, if you find just a few missing values, you can add
them directly to the table. Conversely, if you find that entire columns or a large number of values
are either missing or were not imported properly, you should correct the problem in the source
file. After you have corrected all known problems, repeat the import operation.
Issue Resolution
Graphical Graphical elements, such as logos, charts, and pictures cannot be imported.
elements Manually add them to the database after completing the import operation.
The results of a calculated column or cells are imported, but not the underlying
Calculated
formula. During the import operation, you can specify a data type that is
values
compatible with the formula results, such as Number.
TRUE or If the source worksheet or range includes a column that contains only TRUE or
FALSE and -1 FALSE values, Access creates a Yes/No field for the column and inserts -1 or 0
Issue Resolution
values in the field. However, if the source worksheet or range includes a column
that contains only -1 or 0 values, Access, by default, creates a numeric field for
or 0 values
the column. You can change the data type of the field to Yes/No during the
import operation to avoid this problem.
When you import data to a new table or append data to an existing table, Access
Multivalued does not enable support for multiple values in a field, even if the source column
fields contains a list of values separated by semicolon (;). The list of values are treated
as a single value and are placed in a text field.
If data appears truncated in a column in the Access table, try increasing the width
of the column in Datasheet view. If that doesn't resolve the issue, the data in a
numeric column in Excel is too large for the field size of the destination field in
Truncated data
Access. For example, the destination field might have the FieldSize property set
to Byte in an Access database but the source data contains a value greater than
255. Correct the values in the source file and try importing again.
You might have to set the Format property of certain fields in design view to
ensure that the values are displayed correctly in Datasheet view. For example:
Note: If the source worksheet contains rich text formatting such as bold,
underline, or italics, the text is imported, but the formatting is lost.
Records that you are importing might contain duplicate values that cannot be
Duplicate
stored in the primary key field of the destination table or in a field that has the
values (key
Indexed property set to Yes (No Duplicates). Eliminate the duplicate values in
violation error)
the source file and try importing again.
The date fields that are imported from an Excel worksheet might be off by four
years. Excel for Windows uses the 1900 Date System (in which serial numbers
range from 1 to 65,380), which correspond to the dates January 1, 1900 through
December 31, 2078. However, Excel for the Macintosh uses the 1904 Date
Date values off System (in which serial numbers range from 0 to 63,918), which correspond to
by 4 years the dates January 1, 1904 through December 31, 2078.
Before you import the data, change the date system for the Excel workbook or,
after appending the data, perform an update query that uses the expression [date
field name] + 1462 to correct the dates.
Null values You might see an error message at the end of the import operation about data that
was deleted or lost during the operation, or when you open the table in Datasheet
view, you might see that some field values are blank. If the source columns in
Excel are not formatted, or the first eight source rows contain values of different
Issue Resolution
data types, open the source worksheet and do the following:
The preceding steps can help minimize the appearance of null values. The
following table lists cases where you will still see null values:
The source column in the worksheet contains only numeric values in the
first eight rows, but contains some date values in the subsequent rows.
These date values will be converted incorrectly.
The source column contains date values in some of the first eight rows,
Date values and you attempted to import it into a numeric field. These date values
replaced by will be converted incorrectly.
numeric values
To avoid this, replace the date values with numeric values in the source
column and try importing again.
The source column contains only date values in the first eight rows, but
contains some numeric values in the subsequent rows. These numeric
values will be converted incorrectly.
The source column contains numeric values in some of the first eight
rows, and you attempted to import it into a date field. These numeric
values will be converted incorrectly.
To avoid this, replace the numeric values with date values in the source column
and then try importing again.
In addition, you might want to review the error log table (mentioned in the last page of the
wizard) in Datasheet view. The table has three fields — Error, Field, and Row. Each row
contains information about a specific error, and the contents of the Error field should help you
troubleshoot the problem.
Error Description
Field Truncation A value in the file is too large for the FieldSize property setting for this field.
A value in the worksheet is the wrong data type for this field. The value
Type Conversion
might be missing or might appear incorrect in the destination field. See the
Failure
previous table for more information how to troubleshoot this issue.
Key Violation This record's primary key value is a duplicate — it already exists in the table.
Validation Rule A value breaks the rule set by using the ValidationRule property for this
Failure field or for the table.
Null in Required A null value isn't allowed in this field because the Required property for the
Field field is set to Yes.
Null value in The data that you are importing contains a Null value that you attempted to
AutoNumber field append to an AutoNumber field.
A text value contains the text delimiter character (usually double quotation
marks). Whenever a value contains the delimiter character, the character must
Unparsable Record be repeated twice in the text file; for example:
10 - 3 1/2"" disks/box
Top of Page
Typically, you link to an Excel file (instead of importing) for the following reasons:
You want to continue to keep your data in Excel worksheets, but be able to use the
powerful querying and reporting features of Access.
Your department or workgroup uses Access, but data from external sources that you work
with is in Excel worksheets. You don't want to maintain copies of external data, but want
to be able to work with it in Access.
Remember that you cannot create a link to an Access database from within Excel.
When you link to an Excel file, Access creates a new table, often referred to as a linked
table. The table shows the data in the source worksheet or named range, but it doesn't
actually store the data in the database.
You cannot link Excel data to an existing table in the database. This means that you
cannot append data to an existing table by performing a linking operation.
A database can contain multiple linked tables.
Any changes that you make to the data in Excel are automatically reflected in the linked
table. However, the contents and structure of a linked table in Access are read-only.
When you open an Excel workbook in Access (in the File Open dialog box, change the
Files of Type list box to Microsoft Office Excel Files, and select the file you want),
Access creates a blank database and automatically starts the Link Spreadsheet Wizard.
1. Locate the Excel file and the worksheet or range that has the data you want to link to. If
you don't want to link to the entire worksheet, consider defining a named range that
includes only the cells you want to link to.
a. Switch to Excel and display the worksheet in which you want to define a named
range.
b. Select the range of cells that contain the data you want to link to.
c. Right-click within the selected range and click Name a Range.
d. In the New Name dialog box, specify a name for the range in the Name box and
then click OK.
Note that you can link to only one worksheet or range at a time during a link operation.
To link to data in multiple places in a workbook, repeat the link operation for each
worksheet or range.
2. Review the source data, and take action as described in the following table:
Element Description
Ensure that the cells are in tabular format. If the range includes merged cells, the
Tabular
contents of the cell are placed in the field that corresponds to the leftmost column
format
and the other fields are left blank.
Skipping You cannot skip source columns and rows during the linking operation. However,
columns and you can hide fields and filter records by opening the linked table in Datasheet view
rows after you have imported them into Access.
Number of The number of source columns cannot exceed 255, because Access does not
columns support more than 255 fields in a table.
Blank
columns, Delete all unnecessary blank columns and blank rows in the Excel worksheet or
rows, and range. If there are blank cells, try to add the missing data.
cells
If one or more cells in a worksheet or range contain error values, correct them
before you start the import operation. Note that if a source worksheet or range
Error values
contains error values, Access inserts a null value in the corresponding fields in the
table.
You cannot change the data type or size of the fields in the linked table. Before you
start the linking operation, you must verify that each column contains data of a
specific type.
If the first row in the worksheet or named range contains the names of the columns,
you can specify that Access should treat the data in the first row as field names
First row during the link operation. If there are no column names in the worksheet, or if a
specific column name violates the field naming rules in Access, Access assigns a
valid name to each corresponding field.
If you don't want to store the link in any of your existing databases, create a blank
database.
2. In the Get External Data - Excel Spreadsheet dialog box, in the File name box, specify
the name of the Excel source file.
3. Select Link to the data source by creating a linked table, and then click OK.
The Link Spreadsheet Wizard starts and steps you through the linking process.
4. On the first page of the wizard, select a worksheet or a named range and click Next.
5. If the first row of the source worksheet or range contains the field names, select First
row contains column headings. Access uses these column headings to name the fields in
the table. If a column name includes certain special characters, it cannot be used as a field
name in Access. In such cases, an error message is displayed that tells you that Access
will assign a valid name for the field. Click OK to continue.
6. On the final page of the wizard, specify a name for the linked table and then click Finish.
If the table with the name you specify already exists, you are asked if you want to
overwrite the existing file. Click Yes if you want to overwrite the file, or click No to
specify a different file name.
Access attempts to create the linked table. If the operation succeeds, Access displays the
Finished linking table message. Open the linked table and review the fields and data to
ensure that you see the correct data in all the fields.
If you see error values or incorrect data, you need to troubleshoot the source data. For
more information about troubleshooting error values or incorrect values, see the next
section.
Top of Page
Troubleshoot #Num! and other incorrect values in a linked
table
Even if you see the message Finished linking table, you should open the table in Datasheet
view to ensure that the rows and columns show the correct data.
If you see errors or incorrect data anywhere in the table, take correct action as described in the
following table, and then try linking again. Remember that you cannot add the values directly to
the linked table, because the table is read-only.
Issue Resolution
Graphical Graphical elements in an Excel worksheet, such as logos, charts, and pictures,
elements cannot be linked to in Access.
You might have to set the Format property of certain fields in Design view to
Display format
ensure that the values are displayed correctly in Datasheet view.
The results of a calculated column or cells are displayed in the corresponding
Calculated values
field, but you cannot view the formula (or expression) in Access.
Increase the width of the column in Datasheet view. If you still don't see the
Truncated text entire value, it could be because the value is longer than 255 characters. Access
values can only link to the first 255 characters, so you should import the data instead
of linking to it.
The linked table might appear to be correct, but later, when you run a query
Numeric field
against the table, you might see a Numeric Field Overflow error message.
overflow error
This can happen because of a conflict between the data type of a field in the
message
linked table and the type of data that is stored in that field.
If the source worksheet or range includes a column that contains only TRUE or
FALSE values, Access creates a Yes/No field for the column in the linked
TRUE or FALSE table. However, if the source worksheet or range includes a column that
and -1 or 0 contains only -1 or 0 values, Access, by default, creates a numeric field for the
values column, and you will not be able to change the data type of the corresponding
field in the table. If you want a Yes/No field in the linked table, ensure that the
source column includes TRUE and FALSE values.
Access does not enable support for multiple values in a field, even if the source
Multivalued
column contains a list of values separated by semicolon (;). The list of values
fields
will be treated as a single value, and placed in a text field.
#Num! Access displays the #Num! error value instead of the actual data in a field in
the following situations:
1. Ensure that the source column does not contain values of different data
types.
2. Format the columns in the Excel file.
3. During the linking operation, select the right data type for each field. If
the data type is incorrect, the resulting column might contain only
#Num! values for all the rows of data.
If you see a seemingly random five-digit number in a field, check to see if the
Numeric values source column contains mostly numeric values but also includes a few date
instead of date values. Date values that appear in numeric columns get incorrectly converted to
values a number. Replace the date values with numeric values and then try linking
again.
If you see a seemingly random date value in a field, check to see if the source
Date values
column contains mostly date values but also includes a few numeric values.
instead of
Numeric values that appear in date columns get incorrectly converted to a date.
numeric values
Replace the numeric values with date values and then try linking again.
Top of Page
Share