>This code, which is called by a button,
>
>for each oControl in thisform.Controls
> if oControl.class = "Mergeclass"
> thisform.RemoveObject(oControl.name)
> endif
>endfor
>
>Leaves 1 instance of the target class remaining on the form. Any ideas why?
>I thought maybe it was a focus issue but focus is switched to the button when it is clicked.
I had fallen into the same trap few months ago, so I now I know that you can not remove an object from a collection using FOR EACH syntax. You need to use a counter and go in reverse order to remove items.
If it's not broken, fix it until it is.
My Blog