Thank You, thats exactly what ive been doing. I think i have found what is making it crash....arc cannot find the feature class dataset - it says feature dataset = nothing. When i look on the layer information it says it has a reference to a dataset on my desktop. Is there something special i need to do to get the dataset? so far my sub looks like this:
Private Sub cmd_Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Calculate.Click
ComboBox1.Items.Clear()
Dim currentDocument As IMxDocument = CType(My.ArcMap.Document, IMxDocument)
Dim currentMap As IMap = currentDocument.FocusMap
Dim activeView As IActiveView = My.ArcMap.Document.ActiveView
Dim collectionLayers As ESRI.ArcGIS.Carto.IEnumLayer = currentMap.Layers(Nothing, True)
If collectionLayers Is Nothing Then Exit Sub
collectionLayers.Reset()
MsgBox("Check 1")
Dim loopLayer As ESRI.ArcGIS.Carto.ILayer
loopLayer = collectionLayers.Next()
While loopLayer IsNot Nothing
If loopLayer.Name = "SSIM_Geological_Ranking" Then
MsgBox("Found Layer")
Dim SSIMLayer As ESRI.ArcGIS.Carto.ILayer
SSIMLayer = loopLayer
Dim findSSIMlayerID As New SSIM_getlayerindex
Call findSSIMlayerID.GetIndexNumberFromLayerName(activeView, "SSIM_Geological_Ranking")
Dim SSIMlayerindex As Integer
SSIMlayerindex = findSSIMlayerID.i
Dim SSIMfeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer = CType(SSIMLayer, ESRI.ArcGIS.Carto.IFeatureLayer)
Dim SSIMfeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass = SSIMfeatureLayer.FeatureClass
Dim SSIMdataset As ESRI.ArcGIS.Geodatabase.IDataset = CType(SSIMfeatureClass.FeatureDataset, ESRI.ArcGIS.Geodatabase.IDataset)
Dim SSIMworkspace As ESRI.ArcGIS.Geodatabase.IWorkspace = CType(SSIMdataset.Workspace, ESRI.ArcGIS.Geodatabase.IWorkspace)
MsgBox("Found Workspace")
Dim transactions As ITransactions = CType(SSIMworkspace, ITransactions)
transactions.StartTransaction()
MsgBox("Started Transaction")
Try
Dim queryFilter As IQueryFilter = New QueryFilterClass()
queryFilter.WhereClause = "'Basin type' = 'Rift'"
queryFilter.SubFields = "'SSIM Basin Ranking'"
Dim updatecursor As IFeatureCursor = SSIMfeatureClass.Update(queryFilter, False)
Dim typeFieldIndex As Integer = SSIMfeatureClass.FindField("'SSIM Basin Ranking'")
MsgBox("Found fields")
Dim feature As IFeature = updatecursor.NextFeature()
Do While Not feature Is Nothing
feature.Value(typeFieldIndex) = "6"
updatecursor.UpdateFeature(feature)
feature = updatecursor.NextFeature()
Loop
MsgBox("Looped all transactions")
transactions.CommitTransaction()
Catch comEx As COMException
transactions.AbortTransaction()
End Try
End If
ComboBox1.Items.Add(loopLayer.Name)
End While
MsgBox("Done")
End Sub