In my app, everytime a user creates a form, that form is given an ID. This ID is based on the number of forms currently in the datasource + 1. Meaning if there are currently 10 forms in the datasource, the next created form is generated at 11.
My app also has a delete form function, that deletes the form based on its ID. The problem here is that if a newer form is deleted, such as 9 (and assuming there are 11 forms in the datasource), my app will count that there are 10 forms in the datasource and generate the newest form at ID = 11. So now if that form needs to be deleted, there are two ID 11s, meaning that both will be deleted.
I'm wondering if there is a way to lookup which numbers are unused and assign that unused number as the ID? Or if there is a way to bump the IDs down (if 9 is deleted, 10 becomes 9 and 11 becomes 10)? I am using excel as my datasource.