>Hi,
> I have a top level form and multiple MDI form. I place toolbar on my top level form and issue _SCREEN.ACTIVEFORM.mymethod(). It works most of the time, but VFP give error ACTIVEFORM is not an Object sometime... why does it happen? hor to solve?
>
There are numerous times when there is no ActiveForm available - nothing is running in the context of _SCREEN, the system is transitioning between forms, or the Form with focus has no active and visible controls. This is well-documented in the on-line help for ActiveForm and ActiveControl. Before using these for reference, it is strongly advised that you check that they are valid by:
IF TYPE("_SCREEN.ActiveForm") = "O" AND NOT ISNULL(_SCREEN.ActiveForm)
and
IF TYPE("_SCREEN.ActiveControl") = "O" AND NOT ISNULL(_SCREEN.ActiveControl)
The same applies to FormSet.ActiveForm and Form.ActiveControl, or the _VFP. or Application. object references.