My project have invoice no.I want to run the invoice no.in Auto Number.please help with the right code.

put auto increment in the data field of the data base. every database has this option.

i use my own auto number by this method
first of all load the last entery
then adding 1 in that entery
eg

Dim DBConn As ADODB.Connection
Set DBConn = New ADODB.Connection

    DBConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
                & "Data Source=" _
                & GetAppPath _
                & "anyname.mdb"
Dim rSearch As ADODB.Recordset
        Set rSearch = New ADODB.Recordset
        rSearch.Open "tablename", gobjConn, adOpenDynamic, adLockPessimistic
If rSearch.BOF = True And rSearch.EOF = True Then
        LblID.Caption = "200001"    'this is if there is no record and it is 'going to be the first entery
    Else
        rSearch.MoveLast 'here there are enteries in the database
        LblID.Caption = rSearch!ID + 1  ' eg 200001 + 1 se new Auto Number 'will be 200002
    End If
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.