Of course it shows "Error". The code that does the if and trace runs before you have a chance to click the button.

When do you want that code to run?