define classs myButtonClass as CommandButton cMyGroup = "" && your custom property function click select * from MyStockFile where Stock_Group = This.cMyGroup endfunc enddefineThen, when you dynamically add the buttons to the form, be sure to set this property corresponding to your group
select distinct Stock_Group from MyStockFile into cursor C_Temp select C_Temp scan lcBtn = "Btn" + allt( str( recno( "C_Temp" ))) Thisform.AddObject( lcBtn, "MyButtonClass" ) WITH Thisform.&lcBtn .cMyGroup = C_Temp.Stock_Group ENDWITH endscanHTH