How to restore a form to a previous state