4
Contributors
3
Replies
22
Views
2 Years
Discussion Span
Last Post by matoo
0

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

0

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
This topic has been dead for over six months. 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.