Modify or change the data type setting for a field

This article explains how to set or change the data type applied to a table field in a Microsoft Office Access 2007 database.

In this article


Understand data types

When you first design and build a database, you plan one or more tables, you plan the fields (columns) for each table, and you set a data type for each field. For example, if you need to store dates and times, you set a field to the Date/Time data type. If you need to store names and addresses, you set one or more fields to the Text data type, and so on.

Office Access 2007 provides 10 different data types (earlier versions of Access provided nine), and each type has a specific purpose. The following table lists the data types, shows the type of data that each stores, and describes the limitations that each type imposes.

Data Type Used to store Limitations/Restrictions
Text Alphanumeric data (text and numbers) Stores up to 255 characters.
Memo Alphanumeric data (text and numbers) Stores up to 2GB of data (the size limit for all Access databases), if you fill the field programmatically. Remember that adding 2GB of data causes your database to operate slowly.

If you enter data manually, you can enter and view a maximum of 65,535 characters in the table field and in any controls that you bind to the field.

When you create databases in the Office Access 2007 file format, Memo fields also support rich-text editing.

For more information, see the articles Format data in tables, forms, and reports, Enter or edit data in a control or column that supports rich text and Insert, change, or delete a Memo field.

Number Numeric data Number fields use a Field Size setting that controls the size of the value that the field can contain. You can set the field size to 1, 2, 4, 8, or 16 bytes.

For more information about Number fields, see the article Insert, create, or delete a field to store numeric values.

Date/Time Dates and times Access stores all dates as 8-byte double-precision integers.

For more information about using Date/Time fields, see the article Insert, create, or delete a field that stores date values.

Currency Monetary data Stores data as 8-byte numbers with precision to four decimal places. Use this data type to store financial data and when you don't want Access to round values.
AutoNumber Unique values created by Access when you create a new record Stores data as 4-byte values; typically used in primary keys.

For more information about primary keys, see the article Add, set, change or remove the primary key.

Yes/No Boolean (true or false) data. Access uses -1 for all Yes values and 0 for all No values.
OLE Object Images, documents, graphs, and other objects from Office and Windows-based programs Stores up to 2GB of data (the size limit for all Access databases). Remember that adding 2GB of data causes your database to operate slowly. OLE Object fields create bitmap images of the original document or other object, and then display that bitmap in the table fields and form or report controls in your database.

For Access to render those images, you must have an OLE server (a program that supports that file type) registered on the computer that runs your database. If you don't have an OLE server registered for a given file type, Access displays a broken image icon. This is a known problem for some image types, most notably JPEG images.

As a rule, you should use Attachment fields for your .accdb files instead of OLE Object fields. Attachment fields use storage space more efficiently and are not limited by a lack of registered OLE servers.

For more information about using attachments, see the last row in this table, and see the article Attach files and graphics to the records in your database.

Hyperlink Web addresses Stores up to 1 gigabyte of data. You can store links to Web sites, sites or files on an intranet or Local Area Network (LAN), and sites or files on your computer.
Attachment Any supported type of file New to Office Access 2007 .accdb files. You can attach images, spreadsheet files, documents, charts, and other types of supported files to the records in your database, much like you attach files to e-mail messages. You can also view and edit attached files, depending on how the database designer sets up the Attachment field. Attachment fields provide greater flexibility than OLE Object fields, and they use storage space more efficiently because they don't create a bitmap image of the original file.

For more information about using attachments, see the article Attach files and graphics to the records in your database.

 Note   In Office Access 2007, you can set the data types for your table fields by working in either Datasheet view or Design view. Steps in this section explain how to set the data type in both views. When you set data types in Design view, you see an 11th choice, Lookup Wizard. That choice is actually not a data type. Instead, you use the Lookup Wizard to create lookup fields, which link foreign key fields to other tables. By default, Access sets lookup fields to the Number data type.

For more information about creating and using lookup fields, see the article Add or change a lookup field that lets you store multiple values.

Finally, data types provide a basic form of data validation because they help ensure that users enter the proper types of data in your table fields. For example, you cannot enter text in a field set to accept only numbers.

Top of Page Top of Page

Change data types

Before you follow these steps, remember that changing a data type might truncate (cut off) some or all of the data in a field, and in some cases may remove the data entirely. For information about how Access changes data when you change a data type, see Restrictions on changing data types, later in this article.

Change data types in Datasheet view

  1. In the Navigation Pane, locate and double-click the table that you want to change.

Access opens the table in Datasheet view.

  1. Select the field (the column) that you want to change.
  2. On the Datasheet tab, in the Data Type & Formatting group, click the arrow in the drop-down list next to Data Type, and then select a data type.
  1. Save your changes.

Change data types in Design view

  1. If you have the table open in Datasheet view, right-click the document tab for the table and click Design View.

-or-

If you do not have the table open, in the Navigation Pane, right-click the table that you want to change, and then click Design View on the shortcut menu.

  1. Locate the field that you want to change, and select a new data type from the list in the Data Type column.
  2. Save your changes.

Top of Page Top of Page

Restrictions on changing data types

As a rule, you can change the data type of all fields, except for:

  • Number fields with the Replication ID property enabled.
  • OLE Object fields.
  • Attachment fields.

In addition, you can change most data types when a field contains data. However, depending on the original data type and the new data type that you want to use, Access might truncate or delete some data, or it may not allow the conversion at all.

The following table lists the possible data type conversions that you can perform in Office Access 2007, and describes any restrictions that Access might impose on the conversion.

Convert to this type From this type Changes or restrictions
Text Memo Access deletes all but the first 255 characters.
Number No restrictions.
Date/Time No restrictions.
Currency No restrictions.
AutoNumber No restrictions.
Yes/No The value -1 (Yes in a Yes/No field) converts to Yes. The value 0 (No in a Yes/No field) converts to No.
Hyperlink Access truncates links longer than 255 characters.
Memo Text No restrictions.
Number No restrictions.
Date/Time No restrictions.
Currency No restrictions.
AutoNumber No restrictions.
Yes/No The value -1 (Yes in a Yes/No field) converts to Yes. The value 0 (No in a Yes/No field) converts to No.
Hyperlink No restrictions.
Number Text Text must consist of numbers and valid currency and decimal separators. The number of characters in the Text field must fall within the size set for the Number field.

For more information about the sizes of number fields, see the article Insert, create, or delete a field to store numeric values.

Memo The Memo field must contain only text and valid currency and decimal separators. The number of characters in the Memo field must fall within the size set for the Number field.

For more information about the sizes of number fields, see the article Insert, create, or delete a field to store numeric values.

Number, but with a different field size or precision Values must not be larger or smaller than what the new field size can store. Changing precision may cause Access to round some values.
Date/Time The dates that you can convert depend on the size of the number field. Remember that Access stores all dates as serial dates and stores the date values as double-precision floating integers.

Access uses December 30, 1899 as date 0. Dates outside of the range April 18, 1899 and September 11, 1900 exceed the size of a Byte field. Dates outside the range April 13, 1810 and September 16, 1989 exceed the size of an Integer field.

To accommodate all possible dates, set the Field Size property of your Number field to Long Integer or larger.

For more information about serial dates and how Access uses and stores date values, see the article Enter a date or time value.

Currency Values must not exceed (or fall below) the size limit set for the field. For example, you can convert a currency field to an Integer field only when those values are greater than 255 and do not exceed 32,767.
AutoNumber Values must fall within the size limit set for the field.
Yes/No "Yes" values convert to -1. "No" values convert to 0.
Hyperlink Not applicable.
Date/Time Text Original text must be a recognizable date or date-time combination. For example, 18-Jan-2006.
Memo Original text must be a recognizable date or date-time combination. For example, 18-Jan-2006.
Number Value must fall between -657,434 and 2,958,465.99998843.
Currency Value must fall between -$657,434 and $2,958,465.9999.
AutoNumber Value must exceed -657,434 and be less than 2,958,466.
Yes/No The value -1 (Yes) converts to December 29, 1899. The value 0 (No) converts to midnight (12:00:00 AM).
Hyperlink Not applicable.
Currency Text Text must consist of numbers and valid separators.
Memo Text must consist of numbers and valid separators.
Number No restrictions
Date/Time No restrictions, but Access may round the value
AutoNumber No restrictions
Yes/No The value -1 (Yes) converts to $1. The value 0 (No) converts to 0$.
Hyperlink Not applicable.
AutoNumber Text Not allowed if the AutoNumber field serves as a primary key.
Memo Not allowed if the AutoNumber field serves as primary key.
Number Not allowed if the AutoNumber field serves as a primary key.
Date/Time Not allowed if the AutoNumber field serves as a primary key.
Currency Not allowed if the AutoNumber field serves as a primary key.
Yes/No Not allowed if the AutoNumber field serves as a primary key.
Hyperlink Not applicable.
Yes/No Text Original text must consist only of Yes, No, True, False, On, or Off.
Memo Original text must consist only of Yes, No, True, False, On, or Off.
Number Zero or Null converts to No, all other values convert to Yes.
Date/Time Null or 12:00:00 AM converts to No, all other values convert to Yes.
Currency Zeroes and Nulls convert to No, all other values to Yes.
AutoNumber Access coverts all values to Yes.
Hyperlink Not applicable.
Hyperlink Text If the original text contains a valid Web address, such as adatum.com , www.adatum.com, or http://www.adatum.com, Access converts the text to a hyperlink. Access tries to convert other values, meaning that you see underlined text, and the mouse cursor changes when you point at the link, but the links do not work. The text can contain any valid Web protocol: http://, gopher://, telnet://, ftp://, wais://, and so on.
Memo See the previous entry. The same restrictions apply.
Number Not allowed when a Number field is part of a relationship. If the original value is in the form of a valid I.P. address (four number triplets separated by a period: nnn.nnn.nnn.nnn) and the numbers happen to coincide with a Web address, the conversion results in a valid link. Otherwise, Access appends http:// to the beginning of each value, and the resulting links are not valid.
Date/Time Access appends http:// to the beginning of each address, but the resulting links will almost never work.
Currency Access appends http:// to the beginning of each value, but like dates, the resulting links will almost never work.
AutoNumber Not allowed when the AutoNumber field is part of a relationship. Access appends http:// to the beginning of each value, but the resulting links will almost never work.
Yes/No Access converts all Yes values to -1 and all No values to 0, and appends http:// to the beginning of each value. The resulting links do not work.

Top of Page Top of Page

 
 
Applies to:
Access 2007