You can use the Evaluate function to get an object reference to it.
lcNewObjectName = 'cntMenu' + ALLTRIM(STR(MenuItems.Key))
obutton = evaluate('THISFORM.'+ lcNewObjectName)
Now you have an object reference to the button.
>I am wanting to be able to add some command button objects 'on the fly' in one of my forms, and give each one a name based on a value in my table.
>
>For example,
>
>DO WHILE NOT EOF()
> lcNewObjectName = 'cntMenu' + ALLTRIM(STR(MenuItems.Key))
> THISFORM.AddObject(lcNewObjectName, 'commandbutton')
> SKIP
>ENDDO
>
>
>My question is: how can I reference these new objects without 'hard-coding' the names of each object?
>
>Thanks for any insight!
>Chris
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao