2

I am a new Arc Objects user, with little ESRI experience.

We are using VBA to create a spatial report on a Map Control using a mdb table. The mdb table contains a Lat and Long field, and this data is collected in the Access application.

For the reporting, we need to display a map with the locations from the mdb table.

My questions are:

  1. How do I access data in a mdb table, as spatial data? Does it have to be registered as spatial? I am not sure if this can be done at runtime or has to be done using Arc Catalog.
  2. At runtime, if the data from the mdb table is in a spatially recognized table, do I just create a new layer, set the symbology, and then set a "where" clause on the new layer?
2

You do not need to access it as a spatial table.You can read them using the JET ENGINE/ODBC. Please see jburka's answer on how to access the access table.

Once you have access to the table, you can show it as an event Layer.

Here is a sample, which shows how you can make an XY event layer, once you have table in a ITable:

http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriGeoDatabase/Create_XYEventSource.htm

1

If you want to ONLY show spatial data(not editable in ArcMap),you don't have to have them registed as spatial,you can simply read them using Jet engine or ODBC/OLEDB drive as any other database and then show them in ArcMap using "Custom Layer" concept.It's no too hard and you can keep all your applications which generate data untouched.

another way,you have to create shape file or personal geodatabase according to the structure of your spatial data,and every time you want to show data in ArcMap,you must crearte that shape file or update geodatabase,then create a feature layer from that table in geodatabase/shape file and add it to map object.

here you can fine more about custom layer: http://edndoc.esri.com/arcobjects/9.1/extendingarcobjects/ch04/AboutCustomLayers.htm and if you need a sample code,exactly like what you said,let me know.

1

The link from Devdatta contains the information for taking an ITable and adding it to your map as an event layer. But you don't need to read the data with JET/ODBC; the AccessWorkspaceFactory will open an MDB regardless of whether the file is registered as a geodatabase and contains the necessary schema. This will open the table (in VBA, as that was specified in the original question):

Dim ws As IWorkspace
Dim factory As IWorkspaceFactory
Set factory = New AccessWorkspaceFactory
Set ws = factory.OpenFromFile("{path to mdb file}", 0)
Dim fws As IFeatureWorkspace
Set fws = ws

Dim table As ITable
Set table = fws.OpenTable("{table name}")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy