<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding Shape File With Access VBA in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291197#M7566</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Your major problem seems to be your shapefile.&amp;nbsp; Something wrong with your shapefile.&amp;nbsp; Try to use Toolbox&amp;nbsp; FeatureClasstoShapefile to generate your shapefile from Access if you can and see the result manually.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think anything's wrong with the shape file; I tried adding it manually in ArcMap and it worked just fine. Besides, the data needed for the shapefile isn't in the database. The shape file contains a map of an area, divided up into sections. The access database contains financial information about each of these sections. If a section meets certain monetary criteria, access will modify the definition expression so that it is drawn in ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the "modify definition expression" code by the way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Aug 2010 17:26:03 GMT</pubDate>
    <dc:creator>DavidDuncan</dc:creator>
    <dc:date>2010-08-05T17:26:03Z</dc:date>
    <item>
      <title>Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291193#M7562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good Morning,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my scenario: I have an access database, an arcMap (.mxd) file, and a shape file. What I would like is for the user to be able to click a button on an access form and have a certain shape file added to the ArcMap file (which is acting as a template). I would then modify the definition query of the shapefile to reflect information taken from the database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been able to open the arcMap file, and add the shape file, but that's when things get weird. The loading animation doesn't stop spinning, and the map display area stops refreshing (it just displays whatever was on the screen last). While the shape file can be found in the "layers" box, you have to "flip" back and forth between different tabs to make it appear (once again, a screen refresh problem). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is what I'm trying to do possible? I'm willing to write this within arcMap if I have to, but I think it would be easier, for the users, to keep all functionality contained in the database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Program Info: Access 2003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [INDENT] [INDENT][INDENT][INDENT][INDENT][INDENT][INDENT] ArcMap 9.3[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the VBA code from my database:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;Option Compare Database&amp;nbsp; &lt;BR /&gt;Option Explicit&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Private arcMapApp As esriArcMap.Application&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;STRONG&gt;Public Sub setUpMap()&lt;/STRONG&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Opens ArcMap, adds the shapefiles, and then modifies their representation&lt;/SPAN&gt; &lt;BR /&gt;On Error GoTo errorHandler&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;[INDENT] Dim productKeyCheck As IAoInitialize&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set productKeyCheck = New AoInitialize&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt; 'We check to make sure that no other instances are running with this key&lt;/SPAN&gt; &lt;BR /&gt; If productKeyCheck.IsProductCodeAvailable(esriLicenseProductCodeArcView) Then&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Initialize ArcView&lt;/SPAN&gt; &lt;BR /&gt;[INDENT] productKeyCheck.Initialize esriLicenseProductCodeArcView&amp;nbsp; &lt;BR /&gt; openMapTemplate&amp;nbsp; &lt;BR /&gt; addShapeFiles[/INDENT]&amp;nbsp; &lt;BR /&gt; Else&amp;nbsp; &lt;BR /&gt;[INDENT] MsgBox "Product Code Unavailable For Use", vbExclamation, _&amp;nbsp; &lt;BR /&gt; "Product Code Unavailable"[/INDENT]&amp;nbsp; &lt;BR /&gt; End If&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; productKeyCheck.Shutdown&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; Set productKeyCheck = Nothing[/INDENT]&amp;nbsp; &lt;BR /&gt;Exit Sub&amp;nbsp; &lt;BR /&gt;errorHandler:&amp;nbsp; &lt;BR /&gt;MsgBox Err.Description, vbExclamation, "Error in setUpMap"&amp;nbsp; &lt;BR /&gt; &lt;STRONG&gt;End Sub&lt;/STRONG&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;STRONG&gt;Private Sub openMapTemplate()&lt;/STRONG&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Opens ArcMap and sets the global variables&lt;/SPAN&gt; &lt;BR /&gt;On Error GoTo errorHandler&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;[INDENT] Dim arcMapDocument As MxDocument&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set arcMapDocument = New MxDocument&amp;nbsp; &lt;BR /&gt; Set arcMapApp = arcMapDocument.Parent&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; arcMapApp.OpenDocument CurrentProject.Path &amp;amp; "\Distribution_Plot_Template.mxd"&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set arcMapDocument = Nothing&amp;nbsp; &lt;BR /&gt; [/INDENT]Exit Sub&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;errorHandler:&amp;nbsp; &lt;BR /&gt;MsgBox Err.Description, vbExclamation, "Error in openMapTemplate"&amp;nbsp; &lt;BR /&gt; &lt;STRONG&gt;End Sub&lt;/STRONG&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;STRONG&gt;Private Sub addShapeFiles()&lt;/STRONG&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Adds the shapefiles to the map template&lt;/SPAN&gt; &lt;BR /&gt;On Error GoTo errorHandler&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;[INDENT] Dim pMap As IMap&amp;nbsp; &lt;BR /&gt; Dim pFeatureLayer As IFeatureLayer&amp;nbsp; &lt;BR /&gt; Dim pFeatureWorkspace As IFeatureWorkspace&amp;nbsp; &lt;BR /&gt; Dim pMxDocument As IMxDocument&amp;nbsp; &lt;BR /&gt; Dim pWorkSpaceFactory As IWorkspaceFactory&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set pWorkSpaceFactory = New ShapefileWorkspaceFactory&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set pFeatureWorkspace = pWorkSpaceFactory.OpenFromFile(CurrentProject.Path &amp;amp; _&amp;nbsp; &lt;BR /&gt; "\Claim_Shapefile\", arcMapApp.Hwnd)&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Set up the feature Layer&lt;/SPAN&gt; &lt;BR /&gt; Set pFeatureLayer = New featureLayer&amp;nbsp; &lt;BR /&gt; Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Goldstone_Brookbank_Claims_605")&amp;nbsp; &lt;BR /&gt; pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName&amp;nbsp; &lt;BR /&gt; pFeatureLayer.Visible = True&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Get the document&lt;/SPAN&gt; &lt;BR /&gt; Set pMxDocument = arcMapApp.Document&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Initialize the map and add the shape file to it&lt;/SPAN&gt; &lt;BR /&gt; Set pMap = pMxDocument.FocusMap&amp;nbsp; &lt;BR /&gt; pMap.AddLayer pFeatureLayer&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set pMap = Nothing&amp;nbsp; &lt;BR /&gt; Set pMxDocument = Nothing&amp;nbsp; &lt;BR /&gt; Set pFeatureLayer = Nothing&amp;nbsp; &lt;BR /&gt; Set pFeatureWorkspace = Nothing&amp;nbsp; &lt;BR /&gt; Set pWorkSpaceFactory = Nothing[/INDENT]&amp;nbsp;&amp;nbsp; &lt;BR /&gt;Exit Sub&amp;nbsp; &lt;BR /&gt;errorHandler:&amp;nbsp; &lt;BR /&gt;Set pMap = Nothing&amp;nbsp; &lt;BR /&gt;Set pMxDocument = Nothing&amp;nbsp; &lt;BR /&gt;Set pFeatureLayer = Nothing&amp;nbsp; &lt;BR /&gt;Set pFeatureWorkspace = Nothing&amp;nbsp; &lt;BR /&gt;Set pWorkSpaceFactory = Nothing&amp;nbsp; &lt;BR /&gt;MsgBox Err.Description, vbExclamation, "Error in addShapeFiles"&amp;nbsp; &lt;BR /&gt; &lt;STRONG&gt;End Sub&lt;/STRONG&gt; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are some screenshots from ArcMap:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When it first opens:&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG src="http://farm5.static.flickr.com/4079/4863245646_eef126752a.jpg" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After clicking on the source tab in the layers view (note that I had navigated between windows before taking this screenshot, hence the code image in the non-refreshing map area).&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG src="http://farm5.static.flickr.com/4141/4862623977_5181960151.jpg" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Moving back to the "display" tab&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG src="http://farm5.static.flickr.com/4138/4862624053_af0d607fab.jpg" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 13:16:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291193#M7562</guid>
      <dc:creator>DavidDuncan</dc:creator>
      <dc:date>2010-08-05T13:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291194#M7563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sur if it will resolve your problem, but add these line (modifiy for your code) at the end of AddShape method, can help you to refresh your TOC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; itfMxdocument.ActiveView.Refresh();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; itfMxdocument.UpdateContents();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Vincent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 15:20:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291194#M7563</guid>
      <dc:creator>vincentLahaye</dc:creator>
      <dc:date>2010-08-05T15:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291195#M7564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just tried out the modified code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your hunch was right, while it did cause the shape file to be listed in the layers box, it did not solve any of the other issues. Thanks all the same.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 15:40:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291195#M7564</guid>
      <dc:creator>DavidDuncan</dc:creator>
      <dc:date>2010-08-05T15:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291196#M7565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;to modify defenition expression use :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; IFeatureLayerDefinition itfDefinitionLayer = itfFeatureLayerP as IFeatureLayerDefinition;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; itfDefinitionLayer.DefinitionExpression = yourfield + " = " + yourvalue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; itfMxDocumentP.ActiveView.Refresh();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your major problem seems to be your shapefile.&amp;nbsp; Something wrong with your shapefile.&amp;nbsp; Try to use Toolbox&amp;nbsp; FeatureClasstoShapefile to generate your shapefile from Access if you can and see the result manually.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Vincent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 16:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291196#M7565</guid>
      <dc:creator>vincentLahaye</dc:creator>
      <dc:date>2010-08-05T16:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291197#M7566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Your major problem seems to be your shapefile.&amp;nbsp; Something wrong with your shapefile.&amp;nbsp; Try to use Toolbox&amp;nbsp; FeatureClasstoShapefile to generate your shapefile from Access if you can and see the result manually.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think anything's wrong with the shape file; I tried adding it manually in ArcMap and it worked just fine. Besides, the data needed for the shapefile isn't in the database. The shape file contains a map of an area, divided up into sections. The access database contains financial information about each of these sections. If a section meets certain monetary criteria, access will modify the definition expression so that it is drawn in ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the "modify definition expression" code by the way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 17:26:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291197#M7566</guid>
      <dc:creator>DavidDuncan</dc:creator>
      <dc:date>2010-08-05T17:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Shape File With Access VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291198#M7567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found a solution! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you save the map while it's stuck in the "spinning globe" phase, close the program, and then open the newly saved file, the shape information appears just fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To achieve this in the code, I first modified "openMapTemplate()" into a more generic "openMap()" subroutine&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;STRONG&gt;Private Sub openMap(filename As String)&lt;/STRONG&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt;'Opens the given file in ArcMap&lt;/SPAN&gt; &lt;BR /&gt; [INDENT] Dim arcMapDocument As MxDocument&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set arcMapDocument = New MxDocument&amp;nbsp; &lt;BR /&gt; Set arcMapApp = arcMapDocument.Parent&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; arcMapApp.OpenDocument filename&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; Set arcMapDocument = Nothing[/INDENT]&amp;nbsp; &lt;STRONG&gt;End Sub &lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then changed the end of "addShapeFiles()" to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;seagreen&amp;quot;;"&gt; 'Initialize the map and add the shape file to it&lt;/SPAN&gt; [INDENT]Set pMap = pMxDocument.FocusMap&amp;nbsp; &lt;BR /&gt; pMap.AddLayer pFeatureLayer&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; arcMapApp.SaveAsDocument CurrentProject.Path &amp;amp; "\MapCopy.mxd"&amp;nbsp; &lt;BR /&gt; arcMapApp.Shutdown&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; openMap CurrentProject.Path &amp;amp; "\MapCopy.mxd"[/INDENT]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not the most elegant of solutions, but it'll get the job done.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Aug 2010 14:29:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-shape-file-with-access-vba/m-p/291198#M7567</guid>
      <dc:creator>DavidDuncan</dc:creator>
      <dc:date>2010-08-06T14:29:05Z</dc:date>
    </item>
  </channel>
</rss>

