>if vartype(_Screen.ActiveForm) = "O" ; > and pemstatus(_Screen.ActiveForm,"BaseClass",5) ; > and upper(_Screen.ActiveForm.BaseClass) = "FORM" then > return _Screen.ActiveForm >else > * use a Do While Loop to cycle through the .Parent properties until you get to an object that's a form > local lotmp > lotmp = _Screen.ActiveForm.Parent > do while .T. > if isnull(lotmp); > or upper(lotmp.BaseClass) = "FORM" then > exit > else > lotmp = iif(vartype(lotmp.Parent) = "O",lotmp.Parent,NULL) > endif > enddo > > return lotmp >endif>Haven't tested this, so YMMV. It may have to be tweaked to add more error trapping.