Updating existing record in Add mode

Updating existing record in Add mode

I am trying to set up a user registration application where a new user can register with a password and a PIN. However if he is already registered, I would like to mail him a PIN generated randomly so he can login with it.

In this scheme, I need to update his existing record in the database with the newly generated PIN and also prevent creating a new record. So I am in the "on Add" mode. If I do this in "validate" or "on success" modes, then I am able to modify the PIN field for the user record but another record for the same user gets generated. If I use "cancel submit" no changes are recorded in the database.

Could you please guide me on how to resolve this.

Thanks
Lakshmi