Modify or change the data type setting for a field Access 2007

Author: mety Nagm Labels::



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 TypeUsed to storeLimitations/Restrictions
TextAlphanumeric data (text and numbers)Stores up to 255 characters.
MemoAlphanumeric 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.

NumberNumeric dataNumber 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.
Date/TimeDates and timesAccess stores all dates as 8-byte double-precision integers. For more information about using Date/Time fields
CurrencyMonetary dataStores 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.
AutoNumberUnique values created by Access when you create a new recordStores data as 4-byte values; typically used in primary keys.
Yes/NoBoolean (true or false) data.Access uses -1 for all Yes values and 0 for all No values.
OLE ObjectImages, documents, graphs, and other objects from Office and Windows-based programsStores 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.
HyperlinkWeb addressesStores 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.
AttachmentAny supported type of fileNew 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.

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.

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.

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.

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.
  2. Select the field (the column) that you want to change.
  3. 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.
  4. 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.
  2. Locate the field that you want to change, and select a new data type from the list in the Data Type column.
  3. Save your changes.

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 typeFrom this typeChanges or restrictions
TextMemoAccess deletes all but the first 255 characters.
NumberNo restrictions.
Date/TimeNo restrictions.
CurrencyNo restrictions.
AutoNumberNo restrictions.
Yes/NoThe value -1 (Yes in a Yes/No field) converts to Yes. The value 0 (No in a Yes/No field) converts to No.
HyperlinkAccess truncates links longer than 255 characters.
MemoTextNo restrictions.
NumberNo restrictions.
Date/TimeNo restrictions.
CurrencyNo restrictions.
AutoNumberNo restrictions.
Yes/NoThe value -1 (Yes in a Yes/No field) converts to Yes. The value 0 (No in a Yes/No field) converts to No.
HyperlinkNo restrictions.
NumberTextText 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.
MemoThe 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.
Number, but with a different field size or precisionValues must not be larger or smaller than what the new field size can store. Changing precision may cause Access to round some values.
Date/TimeThe 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.

CurrencyValues 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.
AutoNumberValues must fall within the size limit set for the field.
Yes/No"Yes" values convert to -1. "No" values convert to 0.
HyperlinkNot applicable.
Date/TimeTextOriginal text must be a recognizable date or date-time combination. For example, 18-Jan-2006.
MemoOriginal text must be a recognizable date or date-time combination. For example, 18-Jan-2006.
NumberValue must fall between -657,434 and 2,958,465.99998843.
CurrencyValue must fall between -$657,434 and $2,958,465.9999.
AutoNumberValue must exceed -657,434 and be less than 2,958,466.
Yes/NoThe value -1 (Yes) converts to December 29, 1899. The value 0 (No) converts to midnight (12:00:00 AM).
HyperlinkNot applicable.
CurrencyTextText must consist of numbers and valid separators.
MemoText must consist of numbers and valid separators.
NumberNo restrictions
Date/TimeNo restrictions, but Access may round the value
AutoNumberNo restrictions
Yes/NoThe value -1 (Yes) converts to $1. The value 0 (No) converts to 0$.
HyperlinkNot applicable.
AutoNumberTextNot allowed if the AutoNumber field serves as a primary key.
MemoNot allowed if the AutoNumber field serves as primary key.
NumberNot allowed if the AutoNumber field serves as a primary key.
Date/TimeNot allowed if the AutoNumber field serves as a primary key.
CurrencyNot allowed if the AutoNumber field serves as a primary key.
Yes/NoNot allowed if the AutoNumber field serves as a primary key.
HyperlinkNot applicable.
Yes/NoTextOriginal text must consist only of Yes, No, True, False, On, or Off.
MemoOriginal text must consist only of Yes, No, True, False, On, or Off.
NumberZero or Null converts to No, all other values convert to Yes.
Date/TimeNull or 12:00:00 AM converts to No, all other values convert to Yes.
CurrencyZeroes and Nulls convert to No, all other values to Yes.
AutoNumberAccess coverts all values to Yes.
HyperlinkNot applicable.
HyperlinkTextIf 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.
MemoSee the previous entry. The same restrictions apply.
NumberNot 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/TimeAccess appends http:// to the beginning of each address, but the resulting links will almost never work.
CurrencyAccess appends http:// to the beginning of each value, but like dates, the resulting links will almost never work.
AutoNumberNot 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/NoAccess 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.

0 comments |

Labels

Blog Archive

Powered by Blogger.

I made these pages for me and my friends to help solving the problem we face regarding Computer & internet, if anyone wants me to answer a question or find out about some information please send me email and I will try to reply.*P.S. some of the article I wrote and the other I found on the internet I posted them in sprit of learning and shearing, please forgive me if you found something you don’t want to be in my blog, email me and I will delete them. Thank you for your interest in my pages.امل نجم Amal Nagm

banner 1 banner 2