Join a Table to a Layer

Created:12/6/2000
Last Modified:8/15/2002
Description:

This sample joins the attributes of the first table in the Table of Contents to the first layer in the Table of Contents in ArcMap. You will be prompted for the join field which must be named the same in both the layer and table for the purposes of this sample. This sample performs the same function as the join command from the layer context menu.

Once the join is completed, you will be able to see it listed in the Joins and Relates tab of layer properties. If the layer's table was opened when you ran the script, you must close and re-open it to see the joined columns.


How to use:
  1. If using the VB 6 sample, browse for and select the TableJoinCmd.dll using the 'Add From File' button on the Customize dialog. If using either .NET sample, open the .NET solution file and build the project.
  2. From the 'Developer Samples' command category, drag the command onto any toolbar.
  3. Make sure that the first layer and the first table in the Table of Contents are the ones that you want to join. Optionally, you can modify the code to specify the proper layer and table.
  4. Click on the command to execute it.
  5. When prompted, provide the name of the join column which must be in both the layer and the table. You can later modify the code to allow different join column names.

Application:
ArcMap

Difficulty: Intermediate


Visual Basic Visual Basic.NET C#
File Description
TableJoin.cls Table join command implementation.
TableJoinCmd.vbp The project file.
TableJoinCmd.RES Resource file.
TableJoinCmd.dll The compiled project.