Create a workflow when the button is clicked. Do a search for the last number, add 1 to it, and then save the new number to the database. This way, your issue might be resolved.