access data type and fields
access data type and fields
Every table in Access is made up of fields. The properties of a field describe the
characteristics and behavior of data added to that field. A field's data type is the most
important property because it determines what kind of data the field can store. This article
describes the data types and other field properties available in Access, and includes additional
information in a detailed data type reference section.
2. In this article
Overview
When to use which data type
Field size property
Data types in relationships and joins
Data type reference
3. Overview
Data types can seem confusing for example, if a field's data type is Text, it can store data that
consists of either text or numerical characters. But a field whose data type is Number can
store only numerical data. So, you have to know what properties are used with each data type.
A field's data type determines many other important field qualities, such as the following:
A field's data type can be predefined or you will select a data type depending on how you
create the new field. For example, if you create a field from the Datasheet view and:
Use an existing field from another table, the data type is already defined in the
template or in the other table.
Enter data in a blank column (or field), Access assigns a data type to the field based on
the values that you enter or you can assign the data type and format for the field.
On the Modify Fields tab, in the Fields & Columns group, click Add Fields, Access
displays a list of data types that you can select from.
Top of Page
Tip: Sometimes, the data in a field may appear to be one data type, but is actually another.
For example, a field may seem to contain numeric values but may actually contain text values,
such as room numbers. You can often use an expression to compare or convert values of
different data types.
The following tables show you the formats available for each data type and explain the effect
of the formatting option.
5. Basic Types
Lookup fields have an additional set of field properties, which are located
on the Lookup tab in the Field Properties pane.
Note: Attachment and Calculated data types aren't available in .mdb file formats.
6. Number
8. Yes/No
Top of Page
The Field Size property also determines how much disk space each Number field value
requires. Depending on the field size, the number can use exactly 1, 2, 4, 8, 12, or 16 bytes.
Note: Text and Memo fields have variable field value sizes. For these data types, Field Size
sets the maximum space available for any one value.
For more details about field properties and how they work with the different data types go to
the Data type reference section. Also read the article Set the field size.
Top of Page
A join is a SQL operation that combines data from two sources into one record in a query
recordset based on values in a specified field that the sources have in common. A join can be
an inner join, a left outer join, or a right outer join.
When you create a table relationship or add a join to a query, the fields that you connect must
have the same or compatible data types. For example, you cannot create a join between a
Number field and a Text field, even if the values in those fields match.
In a relationship or a join, fields that are set to the AutoNumber data type are compatible with
fields that are set to the Number data type if the Field Size property of the latter is Long
Integer.
You cannot change the data type or the Field Size property of a field that is involved in a
table relationship. You can temporarily delete the relationship to change the Field Size
property. However, if you change the data type, you won't be able to re-create the relationship
without first also changing the data type of the related field. For more information on tables
see the article, Introduction to tables.
Top of Page
Attachment
AutoNumber
Calculated
Currency
Date/Time and Date/Time Extended
Hyperlink
Memo
Number
Large Number
OLE Object
Text
Yes/No
12. Attachment
Purpose Used in a field that allows attaching files or images to a record. For example, if
you have a job contacts database, you can use an attachment field to attach a photo of the
contact, or attach documents such as a resume. For some file types, Access compresses each
attachment as you add it. Attachment data types are available only in .accdb file format
databases.
When you attach any of the following file types, Access compresses the file.
You can attach many kinds of files to a record. However, some file types that may pose
security risks are blocked. As a rule, you can attach any file that was created in one of the
Microsoft Office programs. You can also attach log files (.log), text files (.text, .txt), and
compressed .zip files. For a list of supported image file formats, see the table later in this
section.
Property Use
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Access supports the following graphic file formats without the need for additional software
being installed on your computer.
The names of your attached files can contain any Unicode character supported by the NTFS
file system that is used in Microsoft Windows NT. In addition, file names must follow the
following guidelines:
Names must not exceed 255 characters, including the file name extensions.
Names cannot contain the following characters: question marks (?), quotation marks
("), forward or backward slashes (/ \), opening or closing brackets (< >), asterisks (*),
vertical bars or pipes (|), colons (:), or paragraph marks (¶).
Top of Page
16. AutoNumber
Purpose Use an AutoNumber field to provide a unique value that serves no other purpose
than to make each record unique. The most common use for an AutoNumber field is as a
primary key, especially when no suitable natural key (a key that is based on a data field) is
available.
An AutoNumber field value requires 4 or 16 bytes, depending on the value of its Field Size
property.
Suppose that you have a table that stores contacts' information. You can use contact names as
the primary key for that table, but how do you handle two contacts with exactly the same
name? Names are unsuitable natural keys, because they are often not unique. If you use an
AutoNumber field, each record is guaranteed to have a unique identifier.
Note: You should not use an AutoNumber field to keep a count of the records in a table.
AutoNumber values are not reused, so deleted records can result in gaps in your count.
Moreover, an accurate count of records can be easily obtained by using a Totals row in a
datasheet.
Property Use
Determines the amount of space that is allocated for each value. For AutoNumber
fields, only two values are allowed:
The Long Integer field size is used for AutoNumber fields that are not used
as replication IDs. This is the default value. You should not change this
value unless you are creating a replication ID field.
Note: Replication is not supported in databases that use a new file format,
such as .accdb.
Field Size
This setting makes AutoNumber fields compatible with other Long Integer
Number fields when they are used in relationships or joins. Each field
value requires 4 bytes of storage.
The Replication ID field size is used for AutoNumber fields that are used
as replication IDs in a database replica. Do not use this value unless you
are working in or implementing the design of a replicated database.
Format If you are using an AutoNumber field as a primary key or as a Replication ID, you
Property Use
should not set this property. Otherwise, choose a number format that meets your
specific needs.
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Indexed Note: Do not change this property for a field that is used in a primary key.
Without a unique index, it is possible to enter duplicate values, which can break
any relationships in which the key is a part.
Although you can create an index on a single field by setting the Indexed field
property, some kinds of indexes cannot be created in this manner. For example,
you cannot create a multi-field index by setting this property.
Smart
Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Tags
Text
Specifies the default alignment of text within a control.
Align
Top of Page
18. Calculated
The calculation must refer to other fields in the same table. You would use the Expression
Builder to create the calculation. Note, Calculated data types were first introduced in Access
2010. Calculated data types are available only in .accdb file format databases.
Property Use
The result of this calculation will be stored in the calculated column. If this
Expression
column has been saved, then only saved columns can be used in this expression.
Result Type The result of the calculation will be displayed as this data type.
Determines the way that the field appears when it is displayed or printed in
datasheets or in forms or reports that are bound to the field. You can use any
Format
valid number format. In most cases, you should set the Format value to match
the result type.
Decimal
Specifies the number of decimal places to use when displaying numbers.
Places
Caption The label text that is displayed for this field by default in forms, reports, and
Property Use
queries. If this property is empty, the name of the field is used. Any text string
is allowed.
Top of Page
20. Currency
Data in a Currency field is not rounded off during calculations. A Currency field is accurate to
15 digits to the left of the decimal point and 4 digits to the right. Each Currency field value
requires 8 bytes of storage.
Property Use
Determines the way that the field appears when it is displayed or printed in
datasheets or in forms or reports that are bound to the field. You can use any
Format
valid number format. In most cases, you should set the Format value to
Currency.
Decimal
Specifies the number of decimal places to use when displaying numbers.
Places
Displays editing characters to guide data entry. For example, an input mask
Input Mask
might display a dollar sign ($) at the beginning of the field.
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Note: Do not change this property for a field that is used in a primary key.
Although you can create an index on a single field by setting the Indexed field
Property Use
property, some kinds of indexes cannot be created in this manner. For example,
you cannot create a multi-field index by setting this property.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Text Align Specifies the default alignment of text within a control.
Top of Page
Property Use
The label text that is displayed for this field by default in forms, reports,
and queries. If this property is empty, the name of the field is used. Any text
Caption string is allowed.
Examples
o 4/3/07
o 05:34:00 PM
o 4/3/07 05:34:00 PM
Long Date Same as the Long Date setting in the regional settings
of Windows. Example: Saturday, April 3, 2007.
Medium Date Displays the date as dd-mmm-yyyy. Example: 3-
Apr-2007.
Short Date Same as the Short Date setting in the regional settings
of Windows. Example: 4/3/07.
Warning: The Short Date setting assumes that dates between 1/1/00
and 12/31/29 are twenty-first century dates (that is, the years are
assumed to be 2000 to 2029). Dates between 1/1/30 and 12/31/99
are assumed to be twentieth century dates (that is, the years are
Property Use
Long Time Same as the setting on the Time tab in the regional
settings of Windows. Example: 5:34:23 PM.
Medium Time Displays the time as hours and minutes separated
by the time separator character, followed by an AM/PM indicator.
Example: 5:34 PM.
Short Time Displays the time as hours and minutes separated by
the time separator, by using a 24-hour clock. Example: 17:34.
Important: Custom formats that are inconsistent with the date/time settings
specified in Windows regional settings are ignored. For more information
on Windows regional settings, see Windows Help.
Separator components
yyyy Displays all digits in a year for 0001-9999 depending on the date and
time data type supported range.
a/p Twelve-hour clock with the lowercase letter "a" or "p," as appropriate.
For example, 9:34p.
Predefined formats
Property Use
Although you can create an index on a single field by setting the Indexed
field property, some kinds of indexes cannot be created in this manner. For
example, you cannot create a multi-field index by setting this property.
Displays editing characters to guide data entry. For example, an input mask
Input Mask
might display a dollar sign ($) at the beginning of the field.
Required Requires that data be entered in the field.
Specifies whether to show the Date Picker control.
Show Date
Picker Note: If you use an input mask for a Date/Time field, the Date Picker
control is unavailable regardless of how you set this property.
Attaches a smart tag to the field. Smart tags were deprecated in Access
Smart Tags
2013.
Text Align Specifies the default alignment of text within a control.
Supplies an expression that must be true whenever you add or change the
Validation Rule
value in this field. Use in conjunction with the Validation Text property.
Enter a message to display when a value that is entered violates the
Validation Text
expression in the Validation Rule property.
Top of Page
24. Hyperlink
Purpose Use to store a hyperlink, such as an e-mail address or a Web site URL.
Property Use
Allow Zero Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink,
Length Text, or Memo field.
Determines whether to track field value changes. There are two settings:
Yes Tracks changes. To view the field value history, right-click the
field, and then click Show column history.
Append Only
No Does not track changes.
Although you can create an index on a single field by setting the Indexed
field property, some kinds of indexes cannot be created in this manner. For
example, you cannot create a multi-field index by setting this property.
Required Requires that data be entered in the field.
Attaches a smart tag to the field. Smart tags were deprecated in Access
Smart Tags
2013.
Text Align Specifies the default alignment of text within a control.
Unicode Compresses text that is stored in this field when less than 4,096 characters
Compression are stored.
Validation Supplies an expression that must be true whenever you add or change the
Rule value in this field. Use in conjunction with the Validation Text property.
Enter a message to display when a value that is entered violates the
Validation Text
expression in the Validation Rule property.
Top of Page
26. Memo
Purpose Use to store a block of text that is more than 255 characters long and is formatted
text. Note, beginning in Access 2013 Memo data type has been renamed to Long Text.
Property Use
Allow Zero Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink,
Length Text, or Memo field.
Determines whether to track field value changes. There are two settings:
Yes Tracks changes. To view the field value history, right-click the
field, and then click Show column history.
Append Only
No Does not track changes.
Although you can create an index on a single field by setting the Indexed
field property, some kinds of indexes cannot be created in this manner. For
example, you cannot create a multi-field index by setting this property.
Required Requires that data be entered in the field.
Attaches a smart tag to the field. Smart tags were deprecated in Access
Smart Tags
2013.
Text Align Specifies the default alignment of text within a control.
Unicode Compresses text that is stored in this field when less than 4,096 characters
Property Use
Compression are stored.
Validation Supplies an expression that must be true whenever you add or change the
Rule value in this field. Use in conjunction with the Validation Text property.
Enter a message to display when a value that is entered violates the
Validation Text
expression in the Validation Rule property.
Top of Page
28. Number
Purpose Use to store a numeric value that isn't a monetary value. If you might use the
values in the field to perform a calculation, use the Number data type.
Property Use
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Byte — Use for integers that range from 0 to 255. Storage requirement
is 1 byte.
Integer — Use for integers that range from -32,768 to 32,767. Storage
requirement is 2 bytes.
Long Integer — Use for integers that range from -2,147,483,648 to
2,147,483,647. Storage requirement is 4 bytes.
Tip: Use Long Integer when you create a foreign key to relate to
another table's AutoNumber primary key field.
Single Use for numeric floating point values that range from -3.4 x
1038 to 3.4 x 1038 and up to seven significant digits. Storage
requirement is 4 bytes.
Double Use for numeric floating point values that range from -1.797 x
10308 to 1.797 x 10308 and up to fifteen significant digits. Storage
requirement is 8 bytes.
Replication ID Use for storing a globally unique identifier required for
replication. Storage requirement is 16 bytes. Note that replication is not
supported using the .accdb file format.
Decimal Use for numeric values that range from -9.999... x 1027 to
Property Use
9.999... x 1027. Storage requirement is 12 bytes.
Tip: For best performance, always specify the smallest sufficient Field Size.
Determines the way that the field appears when it is displayed or printed in
Format datasheets, or in forms or reports that are bound to the field. You can use any
valid number format.
Specifies whether the field has an index. There are three available values:
Although you can create an index on a single field by setting the Indexed field
property, some kinds of indexes cannot be created in this manner. For example,
you cannot create a multi-field index by setting this property.
Displays editing characters to guide data entry. For example, an input mask
Input Mask
might display a dollar sign ($) at the beginning of the field.
Required Requires that data be entered in the field.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Text Align Specifies the default alignment of text within a control.
Validation Supplies an expression that must be true whenever you add or change the value
Rule in this field. Use in conjunction with the Validation Text property.
Validation Enter a message to display when a value that is entered violates the expression
Text in the Validation Rule property.
Top of Page
Purpose Use to store a Large numeric value that isn't a monetary value. If you might use
the values in the field to perform a calculation, use the Large Number data type.
Property Use
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Although you can create an index on a single field by setting the Indexed field
property, some kinds of indexes cannot be created in this manner. For example,
you cannot create a multi-field index by setting this property.
Displays editing characters to guide data entry. For example, an input mask
Input Mask
might display a dollar sign ($) at the beginning of the field.
Required Requires that data be entered in the field.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Text Align Specifies the default alignment of text within a control.
Validation Supplies an expression that must be true whenever you add or change the value
Rule in this field. Use in conjunction with the Validation Text property.
Validation Enter a message to display when a value that is entered violates the expression
Text in the Validation Rule property.
Top of Page
Purpose Use to attach an OLE Object, such as a Microsoft Office Excel spreadsheet, to a
record. If you want to use OLE features, you must use the OLE Object data type.
In most cases, you should use an Attachment field instead of an OLE Object field. OLE
Object fields support fewer file types than Attachment fields support. In addition, OLE Object
fields do not let you attach multiple files to a single record.
Property Use
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Top of Page
34. Text
Purpose Use to store up to 255 characters of text. Note, beginning in Access 2013 the Text
data type has been renamed to Short Text.
Property Use
Allow Zero Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink,
Length Text, or Memo field.
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text
Caption string is allowed.
Field Size Tip: For best performance, always specify the smallest sufficient Field Size.
For example, if you are storing postal codes of a known length, you should
specify that length as the Field Size.
Determines the way that the field appears when it is displayed or printed in
Format datasheets or in forms or reports that are bound to the field. You can define a
custom format for a Text field.
IME Mode Controls the conversion of characters in East Asian versions of Windows.
IME Sentence
Controls the conversion of sentences in East Asian versions of Windows.
Mode
Specifies whether the field has an index. There are three available values:
Although you can create an index on a single field by setting the Indexed
field property, some kinds of indexes cannot be created in this manner. For
example, you cannot create a multi-field index by setting this property.
Required Requires that data be entered in the field.
Attaches a smart tag to the field. Smart tags were deprecated in Access
Smart Tags
2013.
Text Align Specifies the default alignment of text within a control.
Unicode Compresses text that is stored in this field when less than 4,096 characters
Compression are stored.
Validation Supplies an expression that must be true whenever you add or change the
Property Use
Rule value in this field. Use in conjunction with the Validation Text property.
Enter a message to display when a value that is entered violates the
Validation Text
expression in the Validation Rule property.
Top of Page
36. Yes/No
Property Use
The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
Caption allowed.
Specifies whether the field has an index. There are three available values:
Although you can create an index on a single field by setting the Indexed field
property, some kinds of indexes cannot be created in this manner. For example,
you cannot create a multi-field index by setting this property.
Text Align Specifies the default alignment of text within a control.
Validation Supplies an expression that must be true whenever you add or change the value
Rule in this field. Use in conjunction with the Validation Text property.
Validation Enter a message to display when a value that is entered violates the expression
Text in the Validation Rule property.