You are on page 1of 16

Chapter 2 Tables.

Creating, Browsing, Importing, Linking

Creating and Opening, browsing, Updating, Printing, Linking a Table


Loading Access.
From the screen presented, either create a new blank Access database or open an existing database file.

To Create a new database container: Check off Blank Access database. The next screen display (presented below) will appear once you clock OK (bottom right corner). To modify an existing database: Check off Open existing file and Select the database, if shown in the window, if it is not there Open the database with the normal File Open menu that will be presented on the next screen.. Click OK when done

Note: If you use the File Open or File new command to accomplish the same. Access needs the drive, folder and database name to continue. See below. The screen below requires you to provide the necessary data to enable Access to save your database container on the proper drive and folder with an appropriate file name.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 1 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking Under Save in

Select the drive and folder. Under File name: Give your database a proper name. Unless you give it a name, Access will sequential number a database Db1, Db2 etc. for you. When done, click on Create icon.

Note: You can also use the History, My Documents, Desktop and Favorites to store your database.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 2 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

The following screen is presented. The Objects area indicates you are active in Tables section. To go elsewhere click on one of the the Object name such as Queries or Reports. As this was a new database, no existing Tables, Queries, Reports and Forms will appear. Each item will have to be created. From this panel you would normally Create a new table design Modify an existing table design Open an existing table and display its content. To create a new table, click on Create table in Design view.

Creating a new Table structure.


You can create a new table using the Access Wizard or on your own in design view. The Wizard is a tool that helps you create structures from pre-defined commonly used objects. Experiment with the Wizard if you wish, however, these notes will assist with creating a table without the use of the Wizard. By selecting the New Table icon, Access will bring up the following screen. In Design view, for each of the needed fields, you would add the field name, the data type and the properties for the field. Each row in the Field name dialog is unique field in the table. Each field is further identified as to: Field Name, Type, Description, Size, Format, Decimals, Caption, Index, Rules etc.. This is all explained on the pages that follow.

Note: On the table design screen, the width of the Field Name, Data Type and Description are adjustable. So too is the entire display. To adjust the width, place your pointer between any two columns and move in the desired direction. To adjust the entire image size it is best to stretch from the corners. The list of fields is scrollable.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 3 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

Information on the screen above.


Field Name. Choose as descriptive a name as possible, but a good guide is to keep the name short if the field is of short length, as the field name by default becomes the column title in a Query, Form and or Report. Up to 64 characters long, made up of letters, numbers, spaces and most special symbols except a period, exclamation mark and square brackets. The field name must not start with a space. Data Type. This determines what can be entered into a field. The ten data types supported are: Text (up to 255 characters). Number (digits, + , - and .). Supports whole numbers e.g. 256 and very large and small numbers with up to 28 decimal places. Currency (stores accurate values with cents) and assigns the currency symbol ($). Date/time in MM/DD/YY (Month/Day/Year) format performs accurate date and time arithmetic. Memo Data is much like text, however it is used for long comments (64,000 characters long). Autonumber consists of a number (no decimals) that is automatically incremented by 1 in Access. This can guarantee uniqueness, for you cannot edit this field. As far as I can tell it can only start at 1 and is always incremented by 1. However a variation exists where one can specify that the autonumber is a random number in the - 2 billion to plus 2 billion number range (long integer type). Yes/No Limits the values stored to Yes or No. OLE object data allows fields created in other software (e.g. pictures, drawings, voice messages etc.) to be stored, but not modified in Access. Two additional, rather complex but very powerful data types are possible. They are: Hyperlink (The following was copied from Access help Function key F1). Text or combinations of text and numbers stored as text and used as a hyperlink address. A hyperlink address can have up to three parts: text to display the text that appears in a field or control. address the path to a file (UNC path) or page (URL). subaddress a location within the file or page. screentip the text displayed as a tooltip. The easiest way to insert a hyperlink address in a field or control is to click Hyperlink on the Insert menu. For more information, see Type a hyperlink address in Form view or Datasheet view. Lookup wizard (The following was copied from Access) Lookup Wizard Creates a field that allows you to choose a value from another table or from a list of values by using a list box or combo box. Clicking this option starts the Lookup Wizard, which creates a Lookup field. After you complete the wizard, Microsoft Access sets the data type based on the values selected in the wizard. The same size as the primary key field used to perform the lookup, typically 4 bytes Each part of the three parts of a Hyperlink data type can contain up to 2048 characters

Field Description. This is an optional field that can be up to 255 characters long. Use this to document your table structure. Field Size. Assigns maximum field length, but is only used for Text and Number fields. However you really only need to concern yourself with length for Text fields. For number fields: If a whole number like social insurance number, use Long Integer. For a value that has decimal places use Double. For more information turn to Data types and Field sizes under Access help. Format. Enables you to specify how the data is to be displayed and or printed e.g. Currency - 2 decimal places, Short or Long Date format. November 1999

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 4 of 16

Chapter 2 Tables. Creating, Browsing, Importing, Linking Input Mask. Specifies how the data is be entered over a mask. Examples: (000)-000-0000. A letter or digit entry required. C any character or space, but nothing else. Caption. Label that will be used as column heading in a query and or report instead of the field name. Default value. Access will automatically insert whatever is specified. e.g. todays date (=Date()). Validation Rule. Data must meet the limitations as per specified rules. e.g. Value must not be less than $6.00. More examples follow. Validation Text. The message that will be displayed if validation rule is violated. Required. If yes then user must enter a value, i.e. field cannot be left blank. Allow zero length. If allowed, text with no length e.g. is permitted. Indexed. Maintains an index on all the values of this field to speed up searches and links. A good rule of thumb as to whether or not to assign an index is: It must be assigned to all primary key and linked fields in a relationship. If one does frequent searches and or sorts on this field. Note: If you index a field, you will be prompted as to whether or not duplicate keys are allowed. If no duplicate values are permitted then the field can be assigned a primary key. Additional Field property notes. Acceptable data entry formats are: 5/14/94, 5/14/1994, May 14, 1994, May 4, 1994, May 14. Note: 5/14/00 is assumed to be May 14, 2000. Time is entered as 16:00:00 or 16:00. All dates and times can be formatted (displayed) with a number of short and long date and time formats. Validation rules examples: <> 0 ; 10 OR 900 ; Like Montr??? ; <= #12/31/96# etc.. Null Values. If you do not type a value, Access stores a Null value in the field. Note: To seek out a null value, in the criteria cell of the query specify Null. See example in the Query chapter. Deletion of a Field in the table and the switching the order of a field from one row to another row and row depth. Deletion of a field: Any field can be deleted by 1st selecting it and clicking in the empty box just to the left of the field name. When the symbols turns to and the line highlights, double click on the Delete key. All other rows will move up. Switching a Fields location (order) in the table. Any row (field) can be moved from one location to another by simply selecting the row (click in the box just to the right of the field name until symbol turns to an ). While holding down the left mouse button move the row to its desired location. Changing the depth of a given or multiple rows. By selecting just between two rows, Access will let you stretch the depth of that row and possible the ones below.

Creating, Deleting and Changing a Primary Key.


To assign a primary key to a single field: select the row and click Set primary key button. Note: The Indexed field property will now read: Yes (No Duplicates). To assign a primary key to more than one field: select the first row and while holding down the Ctrl key, click Set primary key button, then select the next row and click the Primary Key button. Note: For each respective field with a primary key, duplicates are permitted (Only on the combination of the two fields are duplicates not permitted). As such, the Indexed field property for each of the respective fields can read: Yes (No Duplicates) or Yes (Duplicates OK). To delete or change a primary key, be sure that you delete any relationships first (See chapter 3). To delete a primary key, in table design, click the Indexes button. Select the entire row with the index to be deleted and press the Del key. Close this window and when you return to the table design window, the primary key should be gone. To change a primary key from one column to another, select the new primary column and click the Primary key button. Note: When leaving the table design, Access will check to see if a primary key has been created. If not, it will prompt you with: No primary key exists, Okay, Cancel the closing of the table design or let Access create a primary key for you. If you pick the latter, Access will add an autonumber field as the primary key.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 5 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

Viewing the contents of a Table


From the Database - Table dialog, Open the required table. This presents the Datasheet View window. This window displays the contents of the table in spreadsheet like format. The Menu and icons displayed also take on a display to assist you with scrolling through the table. As well, you can filter the data you may wish to display. Navigation button: You will find navigation buttons at the bottom of the screen to move through the records quickly. The following symbols do the following: |< First record < Previous > Next >| Last record Scroll up and down the table. If the table has enough rows, you can utilize the scroll bars to the right to move up and down. Add a New Record. Use the >* icon to add a new record to the table. You can also use menu Records - Go To New. Delete a Record. There are numerous ways of deleting a record. Note: The record is not physically deleted, but flagged as having been deleted. The methods to delete are: First select the entire record (click leftmost column). Use the Cut icon From the menu select Edit - Delete Hit the Del key Using the right mouse button, select Cut. Maximize and minimize the size of your view display. Use bottom at the top right of the screen. Find or Replace information. To find a record use the binoculars icon which presents the Find dialog (see below) and complete the required information. This presents one record at a time. Note: The same thing can also use the Edit - Find to do the same. To Replace data, use the Edit - Replace menu and follow the instructions. This can replace a single data field or all matching values in the table. Note: This can also be done in an Update Query (See Query chapter). Sort your table. Use the sort icons to rearrange the display order based on the column that you have selected. There is an icon to sort in ascending order (A:Z) and one for descending order (Z:A). To sort on multiple columns do the following. Under the Records menu, you will find a Quick Sort option. Complete the dialog to let you to sort on multiple columns. Note: The underlying order (physical order) of your table is not changed with a sort. The sort only changes the order of how the data is displayed. Filter the table to only show selected records. Use the Edit/Filter icon. This will bring up a query dialog. This dialog is completed similarly to what is explained in the query sections of these notes. Size the column width on the view datasheet. Position the mouse pointer on the heading row, on the right side of the desired column. Hold the left mouse button to expand or reduce the width. Let go when done. When you close the view you will be prompted to save this display format for future use. Misc. options. Explore the Format menu to hide, freeze and apply font and height to the view. Under the records option, you can prevent the user from changing the information in the table. Select Records -Allow editing. Move a column to a new locations on the datasheet view. This cannot be done here. To do this you must create a query and within the QBE dialog, move the columns around. See explanations in the query window.

Example of a Find Dialog window.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 6 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking Filter icons Find icon

Print & Print preview

Sort icons Replace dialog would let you find and replace all or some of the data.

Design icon. Takes you to the table structure

More Options have been selected. This displays:

Printing the contents of a Table


With the tools described above, once you are satisfied that the data is displayed the way you wish to see it, you can then print the table. As a matter of habit, to save paper, in case something goes wrong, you may wish to preview your printed output before actually printing it on paper. Print Preview Click the Print preview icon (see screen above) Use this to Zoom in on the display, browse through it, set up the print display and print. Close the window when done. Hard copy Print out. You can print from within the Print Preview window or click directly on the Print button or from the File menu select Print. Note: You may want to do a Setup before printing. This will enable you to set margins and select the paper size and orientation. Page setup can be activated only after you have opened the table. The set up will be remembered. Print icon. Clicking on the print icon will immediately print the table according to the default or latest settings.

Copying and Pasting the contents of a Table


One can select the contents of an entire table by clicking in the top left corner box. Once done, click the Copy command to copy it to the clipboard. The full table can be pasted out into Word, PowerPoint, Excel and other software supporting the Copy and Paste feature.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 7 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

Creating a table in Access through direct data entry


Another method of creating a table in Access 2000 is to click on the Create table by entering data and entering the data in the columns presented. An example is given below. The fields are identified as Field 1, Field 2 etc. When you close the table you will be prompted if you would Access to create a primary key for you. When you save the table you will be asked to name it or have it take on a default name such as Table1. Access will examine the data field by field and determine the most appropriate data type such as Date and Number and Text data types.

Importing a Table from another database or Excel and Word


From within Access you can import tables from another source two ways. Next these options are explored.

One of the simplest methods is to use the power of Copy and Paste, albeit there are limitations in terms of the amount of data that can be copied. For example, importing a table from Excel requires the following steps. In Excel, select the table. The first row should contain unique column heading. Copy this selection to the clipboard (use the Copy icon, or right mouse click and select Copy or from the Edit menu and selecting Copy). Switch to Access tables tab and Paste the table into Access (use the Paste icon or right mouse click and select Paste or from the edit menu and selecting Paste). You will be prompted for Yes No response as to whether or not your table has column headings. Respond appropriately. This will create a table named the name of the worksheet in Excel. If required, select the table and rename it to a more meaningful name (select and right click and select Rename). Open the table in design mode and fix the data types and properties to what you require them to be. Assign all foreign keys and a primary key if required.

Copy and Paste method

Import method
In the method above, the data is copied and the properties are assigned in Access. Through importing one is not only able to bring in the data but also assign indexing, primary and foreign keys properties. You should still go back into Access Design and modify the imported structure but often all it entails is assigning more meaningful field length to text fields and formatting the various fields. Of course bringing in a very large table may only be possible via the importing method. Here follow the steps.

In the Tables tab, click New. This will bring up the New Table dialog. Select Import Table. Click OK Note this can also be accessed via the menu through Insert - Table.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 8 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 9 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking On the following panel,

Identify the drive & folder (Look in) at the top and File Name near the bottom (space for file name is not visible). If you are importing an Excel table be sure to identify the file type as Microsoft Excel. The dialog is displayed to the right. Click Import

On the following panel, Select either the Worksheet or the Range Name radio button, to identify where Excel has your data stored. In the example shown, I am using Range names. Specifically I am pointing at the Employee range name. With this selection it shows the data in this table. The date of birth field shows values rather than dates. This will be fixed up later trough table design and formatting.. Click on Next >

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 10 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

On the following panel Be sure to tick off First Row Contains Column Headings. Note: If you fail to do this, your fields will be named Field 1, Field 2 etc. By selecting this, your field names will take on the column headings on the 1st row.

Click Next >.

On the next screen, not shown, indicate the that you would like to create a New table. Click Next.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 11 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

For each field in the table that requires indexing, indicate No or Yes (duplicates OK) or Yes (No duplicates). The latter makes it a candidate for a primary key.

Click Next >.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 12 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

On the following panel

On this panel, select the field with the primary key or else indicate No primary key or possibly have Access create one for you. In this example, the filed No is being assigned the primary key.

Click Next >. On the next screen (not shown), Access asks you to name your table. Give it an appropriate name and click on Finish. The table will be created with all the structure, properties and data. Access will confirm that it worked or not.

Note on Importing a Word table into Access.


You cannot import from a Word table. Instead, copy and paste the Word file into Excel and then import the Excel file to Access.

Linking tables to another database or Excel


From within an Access database you can link to a table outside of your database structure. These links can be to another Access database table, an Excel workbook and other sources. These options will be examined below. .

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 13 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking In the Tables tab, click New. This will bring up the New Table dialog. Select Link table. Click OK Note this can also be accessed via the menu through Insert - Table.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 14 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking From the next panel, Indicate the drive, folder and file name of the file to be linked. Be sure to indicate the correct file type like Access or Excel.

Click Link

From the next panel, Select the table through either the worksheet name or range names.

In the example, the range name Employee was selected. Access displays the first few records. Click Next

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 15 of 16

November 1999

Chapter 2 Tables. Creating, Browsing, Importing, Linking

On the next panel (not shown), Indicate that your table contains column headings in the 1 st row. Click Next.

On the next panel (not shown), Give the table a name. Click Finish.

On the panel shown below, the tables tab shows the link to an Excel spreadsheet is shown by the Excel file type indicator to the left of the file name.

Note: Establish the relationship similar to other relationship links within Access. Of course as this creates a link to an outside the Access database container, should you be moving your database to floppy diskette will also require that all linked tables are moved as well.

Access notes. Author: Leo Kerklaan - McGill University Montreal, PQ, Canada Page 16 of 16

November 1999

You might also like