Follow up
You are right boblarson.
But I created this code to generate number like auto number to make track my work the way I need.
Using auto number makes a lot of problem , specially when I open the form to add new case, when I changed my mind and I close the form and reopen it again will give me new number while the previous number has no record , that is the main reason I am using that code to try control the number .
I hope that is clear to you .
Can you please adjust the program or use your idea and let me see how it works.
I hope that will solve my problem.
I am waiting for your great support .
Thank you