Fabio,
If the object conditionally constructs then your WITH createobject() will throw an error. This code will not error:
myRef = createobject()
if ( vartype( m.myRef ) == "O" )
with m.myRef
endwith
endif
The previous code is correct only if vartype( m.myRef ) != "O"
is a aspected valid condition, otherwise it must fire a error.
This code can resolve this situation:
TRY
WITH createobject()
ENDWITH
CATCH
ENDTRY