Looping through a cursor

Looping through a cursor

posted 12-10-2003 01:58 PM
Im having trouble looping. I think I’ve put the loop in the wrong place or my code is wrong. I would appreciate any help.
Private Sub cmdUpdate_Click()
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pActiveView = pMap

MsgBox pMap.Layer(3).Name

Set pFeatureLayer = pMap.Layer(3)
Do While Not pFeature Is Nothing
Set pFeatSel = pFeatureLayer ‘QI

‘selects the selected feature(s)

Set pSelSet = pFeatSel.SelectionSet

‘Check for a selected feature
Set pFeature = pCursor.NextFeature
If pSelSet.Count >= 1 Then
pSelSet.Search Nothing, True, pCursor
Set pFeature = pCursor.NextFeature
MsgBox “You must be working on a selected site. Please select one.”, vbExclamation
Exit Sub
End If

Dim pFields As IFields
Dim pField As IField

strMonth = InputBox(“Enter Month: “, “Repair Month”)
strYear = InputBox(“Enter Year: “, “Repair Year”)
strRepair_By = InputBox(“Enter name of responsible person: “, “responible person name”)

Dim pWorkspaceFactory As IWorkspaceFactory
Dim pWorkspaceEdit As IWorkspaceEdit
Dim pWorkspace As IWorkspace
Dim pFeatureWorkspace As IFeatureWorkspace
Dim pFeatureClass As IFeatureClass

Set pWorkspaceFactory = New ShapefileWorkspaceFactory

‘The argument in OpenFromFile is the path (without the Shapefile name)
Set pWorkspace = pWorkspaceFactory.OpenFromFile(“\\Pleasgis_web\GIS_Data\Utilities\Water\Projects\Polybutylene_Replacement_Program\Poly_Auto_update\Auto\Polybut_update_Proj”, 0)
Set pWorkspaceEdit = pWorkspace
Set pFeatureWorkspace = pWorkspace

pWorkspaceEdit.StartEditing False

‘The argument in OpenFeatureclass is the Shapefile name (without the extension)
Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass(“polybut_all”)

pFeature.Value(pFeature.Fields.FindField(“Month”)) = strMonth

pFeature.Value(pFeature.Fields.FindField(“Year”)) = strYear

pFeature.Value(pFeature.Fields.FindField(“Repair_By”)) = strRepair_By

pWorkspaceEdit.StopEditing True

End Sub

Matt Miller
GIS Intern
City of Pleasanton

Geo Newbie

Leave a Reply