CalledByForm.PRG LPARAMETERS m.tcCalledFormName IF VARTYPE(m.tcCalledFormName)#"C" ERROR 11 ENDIF LOCAL m.loActiveForm IF TYPE("_SCREEN.ACTIVEFORM")="U" *Called from the command window. RETURN "" ENDIF m.loActiveForm = _SCREEN.ActiveForm IF VARTYPE(m.loActiveForm)#"O" *Called from the menu. RETURN "" ENDIF LOCAL ARRAY laStack[1] ASTACKINFO(laStack) LOCAL m.llSuccess, m.lnX, m.lcActiveFormName, m.lcCallingFormName m.llSuccess = .F. m.lcActiveFormName = UPPER(ALLTRIM(m.loActiveForm.Name)) m.lcCallingFormName = "" m.tcCalledFormName = UPPER(m.tcCalledFormName) *Run backwards through the stack. *Locate the passed form's name. *Once that's found, locate the name *of the form before that. If *the last active form is the form *before the passed form name, that *is the calling form. FOR m.lnX = ALEN(laStack,1) TO 1 STEP -1 IF UPPER(laStack[m.lnX,3]) = m.tcCalledFormName+"." m.llSuccess = .T. EXIT ENDIF ENDFOR IF NOT m.llSuccess RETURN m.lcCallingFormName ENDIF LOCAL m.lnY FOR m.lnY = m.lnX TO 1 STEP -1 IF UPPER(laStack[m.lnY,3]) = m.lcActiveFormName+"." m.llSuccess = .T. EXIT ENDIF ENDFOR m.lnY IF m.llSuccess m.lcCallingFormName = m.lcActiveFormName ENDIF RETURN m.lcCallingFormName