Set it to True or 1.
use Cancel = 1 . Cancel is defined as integer in QueryUnload and Unload events!!

But this code will also stop the unload from 'X' of the Form Control menu!!

private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)
If UnloadMode = 0 then Cancel = 1
Debug.print UnloadMode
End Sub