hey guys i have a code for auto generation of id in my project... when i add another id the number repeats itself...
i recently tried to change the code and then the save codeing didnt work... so i went back with the old one... a lil help pls...

Dim empid As Integer
Call clear
If rs1.State = 1 Then

rs1.Open "select * from empdetails", con, adOpenDynamic, adLockOptimistic
If rs1.EOF Then
txtid.Text = 1
empid = rs1.Fields(0) + 1
txtid.Text = empid
End If
cmdadd.Enabled = False
End If

i have two records 1 and 2... but when i add again... it still generates 2 only...what am i supposed to do?

Let's assume your ID field is called empID. You can determine the next available number by

SELECT newID = MAX(empID)+1
  FROM empdetails
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.