Is it possible to reference a recordset (that is, a single feature) after deleting it? I have features that I have linked via matching attribute fields, and when the “parent” feature gets updated, I have code that auto-updates the linked “child” feature. Now I’m trying to figure out if there is a way to delete the “child” feature if the user deletes the “parent” feature by calling a script using the OnDelete event of the parent feature. But I am finding that once the parent feature is deleted, I no longer know how to reference it.
Here is what I am trying (which is not working). The Console.Print yields “False”.
Sub ManageFeatureDeleted()
'++ get the modified record
Dim pRS, lBookmark
Set pRS = Layer.Records
lBookmark = ThisEvent.Bookmark
pRS.Bookmark = lBookmark
Console.Print pRS.IsDeleted
Dim pBufferLyr
Set pBufferLyr = GetLayerByName(BUFFER_LAYER)
'++ find associated pt buffer feature based on common attribute
Dim iCountB
Dim iCountBNotUpdated
iCountB = 0
iCountBNotUpdated = 0
If (Not pBufferLyr Is Nothing) Then
Dim pBufferRS
Set pBufferRS = pBufferLyr.Records
pBufferRS.MoveFirst()
Do While Not pBufferRS.EOF
If (IsEmptyOrBlank(pBufferRS.Fields("LINK").Value) Or Not(pBufferRS.Fields("LINK").Value=pRS.Fields("LINK").Value)) Then
iCountBNotUpdated = iCountBNotUpdated + 1
Else
'Make the buffer feature layer editable
Map.Layers(BUFFER_LAYER).Editable = True
'Delete the buffer feature
pBufferRS.Delete
'Update the RecordSet
pBufferRS.Update
'Refresh the Map
Application.Map.Refresh(True)
'Make the buffer feature layer not editable
Map.Layers(BUFFER_LAYER).Editable = False
'Make the Poly_Spartina_16 layer editable
Map.Layers("Poly_Spartina_16").Editable = False
iCountB = iCountB + 1
End If
pBufferRS.MoveNext()
Loop
End If
End Sub