Select to view content in your preferred language

closing EditForm dynamically

1196
6
Jump to solution
05-02-2012 12:01 PM
SandraDema
Emerging Contributor
I am trying to close the built-in EditForm dynamically. I want the user to see the form, click a button, causing the Editform to close, and a custom form to open. The following is the code I am using:

dim aForm
set aForm = Application.Map.layers("Parcels").Forms("EditForm")
aForm.close
        set aForm = Application.Map.Layers("Parcels").Forms("Form3")
aForm.show

If, for example, I use this code for Form2 and Form3:
dim aForm
set aForm = Application.Map.layers("Parcels").Forms("Form2")
aForm.close
        set aForm = Application.Map.Layers("Parcels").Forms("Form3")
aForm.show
it works perfectly. It only "kinda" works for the EditForm.

When I select parcel "A" and then click the button I have placed on the EditForm, it calls the correct subroutine and the form will close.
Then, when I click on parcel "B", the EditForm opens showing the information for parcel A, not parcel B. The form is now unresponsive, though I can continue to click on the map. The only way to close the form is to close the program.

I have spent several hours searching forums and the web for a solution and have had no luck.  Has anyone had any success with this?

Has anyone else experienced this?
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RolfBroch
Frequent Contributor
Modify your .vbs according to this

Function BeginEdit
  dim aForm
  set aForm = Application.Map.layers("Parcels").Forms("EditForm")
  aForm.close
End Function

Sub Editform_OnUnLoad()
  dim aForm
  set aForm = Application.Map.Layers("Parcels").Forms("Form3")
  aForm.show
End Sub

And remove onunload="Call OpenForm3" statement in your apl. By naming your subroutine "Editform_OnUnLoad()" it should trigger automatically.

View solution in original post

0 Kudos
6 Replies
RolfBroch
Frequent Contributor
One way of doing this is to open the second form from the onunload event of the first form.

Look at http://forums.arcgis.com/threads/53633-Prevent-OK-Button-from-Closing-Form for some ideas.

Rolf
0 Kudos
SandraDema
Emerging Contributor
Thanks so much for the reply. Opening Form3 is not a problem. The code I am using is fired by the OnClick event of a button I have placed on EditForm.

I have done further testing with the OnUnload event of the form and the OnValidate event of the page for EditForm. Neither of these are being called when EditForm is closed by using aForm.close.
Is there is different syntax necessary to close a built-in form?
0 Kudos
RolfBroch
Frequent Contributor
Could you zip your layer file (.apl) and associated .vbs file and post it?

Rolf
0 Kudos
SandraDema
Emerging Contributor
thanks for looking
0 Kudos
RolfBroch
Frequent Contributor
Modify your .vbs according to this

Function BeginEdit
  dim aForm
  set aForm = Application.Map.layers("Parcels").Forms("EditForm")
  aForm.close
End Function

Sub Editform_OnUnLoad()
  dim aForm
  set aForm = Application.Map.Layers("Parcels").Forms("Form3")
  aForm.show
End Sub

And remove onunload="Call OpenForm3" statement in your apl. By naming your subroutine "Editform_OnUnLoad()" it should trigger automatically.
0 Kudos
SandraDema
Emerging Contributor
By naming your subroutine "Editform_OnUnLoad()" it should trigger automatically.


This is what fixed my problem. Overriding the OnUnload event allows me to dispose the form properly.

Thanks so much for all your help.

Cheers!
0 Kudos