thanks Evan, that works just fine, I don't know why but I was looking for some kind of "exists" function?
I haven't 'added' objects very often, so my experience with this is somewhat limited and your help is much appreciated.
>Hi James,
>
>Each container (and forms are a container) has an Objects collection which contains references to any objects that are part of that container.
>
>So, you could do something like:
>
>LOCAL llGridFound, loItem
>
>*-- Define local variables
>llGridFound = .f.
>loItem = .NULL.
>
>*-- Iterate through the objects in the form
>FOR EACH loItem IN THISFORM.Objects
> *-- If the HSGRID1 control is there,
> *-- set the flag and exit the iterative loop
> IF UPPER( loItem.Name ) = "HSGRID1"
> llGridFound = .T.
> EXIT
>
> ENDIF
>ENDFOR
>
>*-- Now, check for the flag
>*-- and instantiate the class
>*-- if it's not there
>IF !( llGridFound )
> THISFORM.AddObject( "hsgrid1", "grid" )
>
>ENDIF
>
>
>Obviously, you could make this into a more generic "common code" method by passing in the control name that you're looking for rather than hard-coding the HSGRID1 -- and you could do the same thing to instantiate a different class rather than the base grid, yada yada...
>
>HTH.
>
>>How do you test to see if a object has already been added to a form.
>>
>>"if hsgrid1 does not exist already"
>>.addobject('hsgrid1','grid')
>>else
>>"continue"
>>
>>Jim Harvey