In PowerBuilder 8 and later, the OpenSheet and OpenSheetWithParm functions might throw a runtime error on failure instead of returning -1. For example, this occurs when the optional windowtype argument is invalid. To ensure that this error is trapped, wrap the call in a try-catch statement in addition to checking the return value:
integer li_ret try li_ret = OpenSheet(w_child, "w_child_1", MDI_User, 2, Original!) if li_ret <> 1 then MessageBox("OpenSheet failed", "Check arguments") catch (RuntimeError rt) MessageBox("OpenSheet failed", rt.GetMessage() ) // Handle error end try