This.MyObject = m.MyObject
never will be true. When comparing objects, always use the COMPOBJ() function. For example,oFSO = CREATEOBJECT('Scripting.FileSystemObject') oFSO1 = CREATEOBJECT('Scripting.FileSystemObject') ? oFSO = oFSO1 && Returns .F. ? COMPOBJ(oFSO, oFSO1) && Returns .T.Second, you never check for NULL. If NULL is a possibility, as it is in the code you present, then you must check for that.
IF m.THIS.myObject=m.myObjectshould be changed to
IF NOT (ISNULL(this.MyObject) OR ISNULL(m.myobject)) AND COMPOBJ(This.MyObject, m.myObject)However, while it does not generate a C5 error, the command button does disappear. As to why, I don't know.