Working with Databases:
Access 2007/10/13
Intro
Before you start
Project 1:
 Intro to Databases
Project 2:
 Access Basics
Project 3:
 Tables & Queries
Project 4:
 Forms & Reports
Glossary
Appendix
 
Home
Lessons
Archives
About
 
Jan's Illustrated Computer Literacy 101 Logo:Jegsworks Jan's Illustrated Computer Literacy 101


Home > Jan's CompLit 101 > Working with Databases > Tables & Queries > Tables > Link
Icon: Arrow - Previous pagePrevious    NextIcon: Arrow - Next page

Jan's Working with Databases

   Tables & Queries: Tables: Link

In some situations it is better to link to the existing data instead of bringing it into the Access database. Linking allows you to see the current version of the data in Access and yet keep it available for other programs to use. You could still use the data with the original program, for example, a spreadsheet program.

You can only link tables, not queries or other objects like charts, logos, or images.

Icons for Linked Tables

The icon in the Navigation Pane for a linked table has an arrow and an icon for the type of object it is.

Examples of Icons for Linked Table:
  Icon: Linked table Access table
  Icon: Linked Excel worksheet Excel worksheet
  Icon: Linked text file Text file
  Icon: Linked dBase file dBase file

Broken Links

If you move or rename the source file for a linked table or rename the table inside the source file, the link breaks. Links will NOT be updated automatically. You can manually update the link(s) with the Linked Table Manager or recreate the link(s).  But, you must still have access to the source file and know how to tell Access where it is from the location of the Access database. This will be difficult unless you have planned for it! You must think carefully before deciding to link.


Method to Link

  • To include in an existing database, use the Link Wizard:
    Ribbon tab External Data > Button for type of file you want to link to.
    In the Get External Data dialog, choose the third option, "Link to the data source by creating a linked table."
    Proceed through the Link wizard, which is very similar to the Import wizard. 
  • To start a new database with a linked table (not an Access table):
    From inside Access, File or Office button > Open. Select a format (spreadsheet, text file, etc) and a file.
    A new database is created with a linked table.
    Note: If you select an Access database in the Open dialog, the current database will close and the selected database will just open. No links are created in this case.
  • To start a new database that will have a linked Access table:
    Create a blank database and use the Link Wizard.

Properties for a Linked Table

For most table and field properties you must make any changes to the source table from inside the original program.

If the design of a linked table is changed in the original program, Access will use those changes, too, but you will probably need to relink to the table with the Linked Table Manager. If you change your password or user name to access the table, you will have to relink to the table.

Changes allowed from inside Access (Does not affect the original table):

  • Rename the table in the new database.
  • Edit the Format, DecimalPlaces, InputMask, and Caption properties for fields in a linked table, but not the other properties.
  • Format the table's Datasheet View.

Work-around for some properties: Create a form or report and set the properties for the controls that are bound to your fields. But... any properties that were set in the source table, like a ValidationRule, are still in effect. So be careful!

Relationships: If you import or link to two or more tables from a database, any relationships between those tables are imported also.


Icon: Step-by-Step 

Step-by-Step: Link to Tables

 Icon: Step-by-Step

What you will learn: to link to a table
to create relationships between tables
to add a Currency data type fields to linked table
to type a character not on the keyboard
to break links by changing database name
to repair broken links with Linked Table Manager
to break links by changing table name

Start with:  Class disk, worldtravel-Lastname-Firstname.accdb, projects-Lastname-Firstname.accdb

You created a Projects database in earlier in this project and saved it to your Class disk. The new World Travel database has more data on the staff than the Projects database has in its Staff table, but it does not have any of the data on projects. You will link to the tables in the Projects database and create a new relationship. The StaffID numbers are the same for both tables, or else this would not work well!

Link to a Table

  1. If necessary, open the database worldtravel-Lastname-Firstname.accdb from the databases project3 folder in your Class disk.
    Icon: Back Up diskHave you made a backup of the database lately?

  2. From the ribbon tab External Data in the Import & Link tab group, click on the Access button Button: Access (Access 2010).
    The Get External Data - Access Database dialog appears.

  3. Navigate to your Class disk to the folder databases project3 and select the file projects-Lastname-Firstname.accdb.

    Dialog: Get External Data - Access Database - project

  4. Click on the option "Link to the data source by creating a linked table."

  5. Click on OK.
    The Link Tables dialog appears.

  6. Dialog: Link TablesSelect the tables Projects and Project Staff.

  7. Click on OK.
    Database Window: Linked tablesThe tables show in the Navigation Pane with the icon for a linked table.
     


Create Relationships Between Tables

Linked tables that have a relationship still have that relationship in the new database.

  1. Icon: Relationships Click on the Relationships button Button: Relationships (2003) in the Database Tools ribbon tab.

  2. If necessary, click on the Show All Relationships button Button: Show All Relationships.

    Show All Relationships

    There are three sets of joins:

    • Linked tables:
      Projects and Project Staff
    • Imported tables:
      Trips and Discounts
    • Lookup wizard:
      Divisions and Locations are joined to Staff
  3. Click on Button: Show Table the Show Table button to open the Show Table dialog, and add the missing table Clients.

    Relationships

    Arrange them neatly, similar to the illustration:

  4. Create the relationships shown in the illustration:

    Project Staff to Staff matching StaffID with EmployeeID
    Trips to Staff matching AgentID with StaffID
    Clients to Trips on ClientID

    Icon: TroubleProblem: Wrong fields were matched
    You dragged a matching field from one table to another but dropped it on the wrong field,
    Solution: Click on the join line to select it. (It will get wider.) Press the Delete key. A confirmation message box appears. Click on OK to continue to delete the relationship.
     
    Note:
    When linking tables, you must be careful to match the correct fields and that those fields have the correct data types. The field names do NOT have to be the same for the relationship to work correctly. But the data type MUST match. This is a particular problem with linked tables, where mismatches can easily occur.

  5. Icon: Save Click the Save button on the toolbar to save your changes.

  6. Close the Relationships window.


Add Currency Fields to Linked Table

The Projects table needs more records and two more fields, Cost and Budget. You can add data to a linked table and make some changes to the table design, but not many. The properties Format, Input Mask, Decimal Places, and Caption can be changed. The table's name can be changed, also.

  1. Datasheet View: Linked Projects table (Access 2013)Icon: Datasheet View Open the linked Projects table in Datasheet View.
    There are three records with three fields.
  2. Icon: Design View Switch to Design view for the table.
  3. Add a new field named Cost.
  4. Select the data type Currency.

    The currency formatting will match the default currency from the Regional and Language Options dialog in the Control Panel. If you choose English - American, you see $ as the currency symbol and a period before the decimal part of a number. If you choose Spanish - Paraguay, you see Gs as the currency symbol and a comma before the decimal portion of the value. You must know what country you are in!

    The default value for a number field is zero. You won't have a null value for this type of field.

  5. Add another field named Budget with the same characteristics.
  6. Message: Access cannot save property changes to a linked table (Access 2013)Icon: Save Save the table.
    Whoops. Access shows a message telling you that it cannot change fields in a linked table.
  7. Click on No.
  8. Close the table.
    Another message box appears, asking if you want to save changes to the table.
  9. Click on No.
    To add new fields you must go to the original database.
  10. Start a new instance of Access and open the Projects-FirstnameLastname database from your Class disk.
    You now have two databases open.
  11. Icon: Design View Open the table Projects in Design View.
  12. Add two new fields, Cost and Budget, both with Currency data type.
  13. Complete records 1-3 with their cost and budget numbers, as in the illustration.

    Projects table with two new fields and data (Access 20130

  14. Icon: Save Save the table but do not close it or the Projects database.

Type Character Not on Keyboard

A standard font has more characters in it than show on the keyboard. There are special key combos that will let you type these characters. The Character Map app can show you what the key combo is. One of the new records you will enter below has a Portugese character that is not on an English keyboard.

Character Map: ã (Win10)Icon: TroubleProblem: How to type characters not on the keyboard
To type ã in the medical conference record below (for São Paulo), hold the ALT key down and on the numeric keypad press 0227.  Now you know one code! You can find the code for other characters in the Character Map program that comes with Windows. If your keyboard does not have a numeric keypad, you will have to open Character Map and copy and paste the symbol.

  1. Icon: Datasheet View Switch to the World Travel database and open the linked Projects table in Datasheet View.
    The linked table looks just like the table you just edited.
  2. Add the following additional records:
     
    ProjectName ProjectDescription Cost Budget
    Late Winter Sale Promoting travel to warm climates at end of winter season $225.00 $250.00
    Recruitment for Australia Campaign to hire agents and other staff for the new Australia regional office $5,125.00 $5,000.00
    BMA Medical Conference Meeting planning/setup for medical conference in São Paulo, Brazil   $8000.00
    Networking Upgrade Researching choices for systems and vendors for a new network   $100.00

     

    Projects table with records 4 - 8 (Access 2013)

    Some versions use the default value of $0 when a Currency field is left blank.

     

  3. Delete any zeroes ($0) in the new records.
  4. Button: Save (Access 2010) Close and save the table.

  5. Icon: Datasheet View Switch to the Projects database.
    The Projects table shows the new records. Sweet!

    Icon: Trouble Problem: New records are not showing
    Solution: Refresh the view by pressing the F5 key on your keyboard or click the Refresh All button on the Home ribbon tab.


Propagate Field Changes

  1. Close the Projects database and return to the World Travel database.

  2. Warning in Table Design View: This property cannot be modified in linked tables.

    Icon: Design View Switch to Table Design View for the linked Projects table.

    A message appears at the bottom right of of window tells you that the current property (the ProjectID field) cannot be modified in a linked table.

    If you do not notice this message and make a change anyway, you will see a popup message.

    Message: Table is linked with some properties that can't be modified.

    That's not completely true. Some properties apply only in the current database.

  3. Inspect each of the properties in the bottom of the Design view for each of the fields.
    Most show the warning. 
  4. Design View: no decimalsFor the Budget field, change the property Decimal Places to zero.
    A button appears for Property Update Options.
  5. Hover over the options button until the down arrow appears, then click.

    Two choices appear -  to update this change everywhere the field Budget is used or to open Help about such updating.
     

  6. Help: Propagate a field propertyClick on "Help on propagating field properties" and read the article that appears. (This article is in the online Help articles.)

    A field's properties which are set in the table's design are carried forward to any controls on forms and reports that use that field. But, if you make a change to the field later, you must propagate the change or those controls will not know about the change.

  7. Close the Help window.

  8. Open the Property Update Options again and select the first choice, Update Decimal Places....
    Message: No objects needed to be updated.A message appears. No objects need to be updated. Well, of course not! You have not yet created any forms or reports in this database! But it's nice to know how this works BEFORE creating a lot of objects.
  9. Click on OK to close the message box.
  10. Icon: Save Close the linked Projects table and save changes.

Break Links: Change Database Name

If the Projects database is renamed or moved, the links to its tables will break.

  1. Open a File Explorer/My Computer window and navigate to the folder on your Class disk where you saved the Projects database. Do not open the database.
  2. Rename the file as projects2-Lastname-Firstname.accdb , with your own first and last names, of course.
  3. Switch back to Access with worldtravel-Lastname-Firstname.accdb open.
  4. Icon: Datasheet View Message: Could not find file...Open the linked table Projects in Datasheet View.
    Whoops.  A message appears telling you that Access cannot find the database file that contains the linked table. Of course not! You changed its name. The same message would appear if you moved the file to a different folder or disk or if you moved the World Travel database.

    Nothing about the link in the Navigation Pane changed to show you that there was a problem.

  5. Click on OK to close the message.

Repair Broken Links: Linked Table Manager

Access has a utility feature called Linked Table Manager to help you repair the link. You just have to be able to find the database!

  1. On the External Data ribbon tab, click on the button Linked Table Manager Button: Linked Table Manager (Access 2010) Button: Linked Table Manager (Access 2016).

    Dialog: Linked Table ManagerThe Linked Table Manager dialog appears listing the linked tables and the path to the source database for each one.

    The dialog allows you to update the links individually if you wish. If all the linked tables are from the same database, you can update them all at once.

  2. Click the button Select All.
    A check mark appears beside each linked table.
  3. Dialog: Select New Location for Project Staff (Access 2010)Click on OK.
    A dialog appears for you to select the correct database.
    The title for the dialog mentions only the first linked table but all items that were selected will be updated to the new source location.
  4. Navigate to your Class disk to the folder databases project3
  5. Select the database projects2-Lastname-Firstname.accdb .
  6. Message: All selected linked tables were successfully refreshed (Access 2010)Click on Open.
    A message appears telling you that you were successful.
  7. Click on OK.
    You are back in the Linked Table Manager.
  8. Click on Close.
    You are back in the Access window.
  9. Database Window: Linked tablesIcon: Datasheet View Open the linked table Projects in Datasheet View.
    Success!
  10. Close the table.

Break Link: Change Table Name

Another way to break a link is to change the name of the table in the original database.

  1. Open the database projects2-Lastname-Firstname.accdb from your Class disk.
  2. Rename the table Projects as Project, without the 's'.
    (Right click on the name and choose Rename from the context menu.)
  3. Switch to the database worldtravel-Lastname-Firstname.accdb.
  4. Icon: Datasheet View Open the linked table Projects .
    An error message appears telling you that Access cannot find a table with that name.

    Message: The Microsoft Jet database engine cannot find the input table or query 'Projects'. Make sure it exists and that its name is spelled correctly.

    This is a different message from when the name of the database changed.  
  5. Click on OK.
  6. Switch back the the Projects database and change the table's name back to Projects.

    TipWhen you do not want to change a table's name back, you can use the Linked Tables Manager to update the link to the new table name.

  7. Close the database Projects-Lastname-Firstname.accdb.
  8. Icon: Datasheet View Switch to the World Travel database and try to open the linked table Projects again in Datasheet View.
    Success!
  9. Close the table Projects.