I haven't tested it and I know from previous experience that it is difficult to get a "app.execMenuItem("Close");" script to work. The best we achieved was to have a hidden numeric field with the initialised value set to zero. This hidden field had script, if its value was changed to 1 then it executed the "close" script.
If the criteria was met that the file should not be opened instead of the app.alert above we had script thta changed the value from 0 to 1, invoking the "close" event. Because the PDF had changed (numeric field changing from 0 to 1) the user was asked if they wanted to save the file before closing. As part of that was a cancel button, which if clicked meant that the file did not close.
This was a real messy work around, so I will be interested to see if someone has a more elegant solution.
Thank Niall! works great!
How about making the subform presence hidden? For me that makes the form useless. 😄