> > I am trying to replace a button at runtime. I am using:
> >
> > theform.navigate1.RemoveObject( [btnDelete] )
> >
> > theform.navigate1.AddObject( [btnDelete], [CastBtnDelete] )
> >
> > But I get an 'Object Name is Invalid' error when I try and do the AddObject.
> >
> > If I change the AddObject call to:
> > theform.navigate1.AddObject( [btn2Delete], [CastBtnDelete] )
> >
> > then it works fine. So it is finding my object. There are other references to
> > the object so I was hoping to keep the object name the same.
> >
> > Is this possible?
> >
> > Bob
>
> Bob,
>
> it looks like your "btnDelete" is not actually removed from the containing form, hence the error: VFP thinks that you are trying to duplicate an object, or add an object of the same class and with the same name as the one already existing.
>
> HTH.
>
> Regards,
>
> Ilya
Well the Delete button disappears from the form.
Also any lines after the Addobject would complain that btnDelete was not a valid object.
So it would appear that it did was removed.
Bob