how to make auto numbering for an ID?
but id has been given an initial value,
examples of initial value: 100027
how to make the ID is automatically incremented by 1?

5 Years
Discussion Span
Last Post by vividiah

Do you want to start with seed value: 100027 everytime ?
If that is the case then you can store seed as a variable, set it to 100027 and store the incremented value in another variable say falg1.

Then do ---> seed=flag1 when your program begins, and flag1=falg1+1 when you wish to increment.

If your scenerio is different, let me know.


yes I want to start with value: 100027,
your scenario is similar to what I want,
indeed such a groove that I have planned,
and I need your help Rahul47,



Okay, first of all explain clearly what you want to do ? With all the components involving, such as tables, forms, database.

Feel free to PM.


Okay I will explain it in detail,
Here I have
Text1 = to display the ID
and I put the code of the ID in the Form_Load order ID automatically appears in Text1.
I use sql server for the database,
so that I can explain, if you still are not clear just ask,


so what problem you are facing now

this is my problem,
I use sql server 2005 database,
and in it there is data along with its ID,
in my program, I want to show that there is a maximum ID in the ID field in the database for TextBox1,
then after I have saved the data to be inserted into the database, then my ID automatically incremented by 1,
This could be called auto increment,
do you know what I mean?
If you still do not understand, you can ask again,


still i don't understand the exact problem as you didn't specify the problem.
But try this

initialise the value for id (which is in recordset) to a variable. ok.
and you can do it very easily like idvar=rec("Field_Name")

now increment the value of idvar by 1 .
for this , write idvar=idvar+1

display idvar to the textbox . ok.
and you have to write like Text1.Text=idvar

Now when you save the data to the database then your all data will be stored with one incremented value(like auto increment) and incremented value should be place under ID Field.

i assumed that are familiar with database connectivity
hope you get the concept.


I've tried it but still can not,
My problem is I have determined the initial value, but it still can not grow 1 or auto increment,


did you use idvar=idvar+1
for example :- the initial value you determine is 101 then first initialise 101 to idvar then increment the idvar by 1 as above.

if still facing problems then don't be hesitate and ask your query freely


oh I am beginning to understand your point, and I've implemented into my program and it finally succeeded,
thanks for all your help so far,


its pleasure.
if it really help then please mark this thread as solved.

happy coding . . .

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.