Not sure, but I seem to recall having an issue with putting if/then/else/endif on the same line. Might be a syntax thing where you need to put wend on its own?

Worth a shot?

Picster