Hi,
I have an access 2007 database with a form that adds tower information to several tables in that database. Since one of the attributes we add is the coordinates, we want to keep a feature layers for these towers in a separete file geodatabase and update it using the same form in the first access 2007 database.
Unfortunately, I get a run-time error / automation error when I try to open the file geodatabase from the access 2007 form. I have also tried with a personal geodatabase, but I got the same error.
Curiously, if I run the code from within ArcMap, it works like a charm.
I don't know if there is any restrictions on accessing the geoDatabase from outside an ArcMap Document or I am missing something else .
Thank you very much,
casti
' these are the libraries I have referenced
' ESRI GeoDatabase Object Library
' ESRI DataSourcesGDB OBJECT Library
' ESRI Geometry Object Library
Public Sub createFeatureFromXYCoordinates()
' Subtask 1. Access the States feature class.
Dim pWSF As IWorkspaceFactory
Dim pFWS As IFeatureWorkspace
Dim pFC As IFeatureClass
Set pWSF = New FileGDBWorkspaceFactory
Set pFWS = pWSF.OpenFromFile("C:\feature_lyr_from_table_view_filegdb.gdb", 0) ' i got the error here
Set pFC = pFWS.OpenFeatureClass("GIS_Info_Spatial")
MsgBox "There are " & pFC.FeatureCount(Nothing) & " mets"
' Get coordinate system.
Dim geoDataset As IGeoDataset
Set geoDataset = pFC
Dim gcs As IGeographicCoordinateSystem
Set gcs = geoDataset.SpatialReference
' Create a new point using the gcs.
Dim pPoint As IPoint
Set pPoint = New Point
Set pPoint.SpatialReference = gcs
pPoint.PutCoords -121.35, 50.01
' Create a new feature.
Dim feature As IFeature
Set feature = pFC.CreateFeature
Set feature.Shape = pPoint
feature.Store
MsgBox "Now there are " & pFC.FeatureCount(Nothing) & " mets"
End Sub