If you would use a UDF maybe OpenFile() it could use the EXIT command to set @error based on the return code directly from the open command.

As you have seen, you can not set @error with if exist.
_________________________
Home page: http://www.kixhelp.com/hb/