how to fire code only when editor first starts (and not when edits are saved/stopped)

686
1
02-23-2012 05:31 AM
JillMasters
New Contributor
I think I must be missing something obvious and fundamental...

I need to know how to fire a procedure (Private sub LoadTableNameArrayFromDB) ONLY when an editing session begins.

I have tried:

  • Including a call to the procedure from editorevents_onstartediting which results in the procedure firing every time edits are saved or closed (not acceptable) as well as when an editing session begins.


  • Listening to "save edits" and "stop editing" actions and setting a boolean variable to true only if the user is stopping edits. My idea was that when this same boolean var was read in the editorevents_onstartediting in the next editing session, the procedure would fire appropriately. However the boolean variable value did not persist between edit sessions.
I am surely missing something obvious about gettting non-object, global variables to persist outside an edit session, since plenty of code is written outside editing sessions.

My customization is complete except for this issue. Please help! My customization includes 2 forms and 6 modules grouped by module actions (such as loading arrays, entry validation, data upload, database connection, etc) and is written in vba in ArcGIS 10 using an Oracle 10 sde geodatabase.

Thanks,
0 Kudos
1 Reply
JillMasters
New Contributor
RESOLVED

My boolean var gb_NewEditSession was persisting but located in the wrong place because I didn't understand event firing sequence.

INSIGHT: When the user stops editing _OnStopEditing fires before _OnSaveEdits (while the reverse is true when the user saves edits)! Since _OnStopEditing fires both when edits are saved and when edits are stopped, I moved my var assignment to _OnStopEditing, conditional to whether "save edits" or 'stop editing" fired the _OnStopEditing listening event:

Private Sub EditorEvents2_OnSaveEdits()
On Error GoTo EH

gb_SaveOnly = True 'set condition used by _OnStopEditing

Exit Sub
EH: MsgBox Err.Description, vbInformation, "On Save Edits"
End Sub

--------------------------------
Private Sub EditorEvents_OnStopEditing(ByVal Save As Boolean)
On Error GoTo EH:
<clip>

'PURPOSE: Boolean used by _onstartediting to determine if new editing session
If gb_SaveOnly = True Then
gb_NewEditSession = False
Else
gb_NewEditSession = True
End If

<clip>
Exit Sub
EH: MsgBox Err.Description, vbInformation, "On Stop Editing"
End Sub

Note: In my previously attached code gb_NewEditSession was called gb_CheckdbMetatables
0 Kudos