Select to view content in your preferred language

subforms will not clear

629
2
12-15-2010 07:29 AM
markfarina
New Contributor
Hello,

I created this form (EDITFORM) with buttons that open subforms (ADDNEWHORIZON1, ADDNEWHORIZON2, etc) that have comboboxs and edit fields. The problem I am having, is that when I create a new point feature the subforms are populated with the previous point feature values.  The controls don't clear themselves.

How do I fix this?

Thanks
Tags (3)
0 Kudos
2 Replies
markfarina
New Contributor
Here is the solution to my problem. Does anyone know if all controls can be cleared at the page level instead of each individual contol???

Thanks

Called on the onload event for subform1

Sub InitH7
Dim FC
Set FC=Application.Map.Layers("pointlayer").Forms("AddNewHorizon1").Pages.Item("PAGE1")                    
'clear control values
FC.Controls.Item("H7").Value=""
             FC.Controls.Item("H7TDepth").Value=""
             FC.Controls.Item("H7BDepth").Value=""
End Sub
0 Kudos
EricHajek1
Occasional Contributor
Hi, you could do something like:

Dim page, objForm, control
objForm = ThisEvent.Object 
'This assumes you're firing this sub from a form-level onload event, you could also just get a direct
'reference or leave the form-level out of it and just use the page-level stuff if you want to do it on a 
'per-page basis

For each page in objForm.Pages
 page.Activate
 For each control in page.Controls
  If control.Type = "COMBOBOX" Then
   control.Clear
   control.value = ""
  ElseIf control.Type = "EDIT" Then
   control.value = ""
  End If
 Next
Next

If you have some radio buttons or checkboxes, you can add more ways to handle it by adding onto the If Then cascade. Credit goes to whoever originally posted the above sub in these forums, I was also doing it "the hard way" before I realized I could use the control and page collection objects this way.

Hope this helps!
0 Kudos