I've a field, say "Invoice No.", i want to be this as an auto-generated number.
like DLP/001/2013-2014 DLP/002/2013-2014 DLP/003/2013-2014 .
I use vb6 and Access.how can i do this?

Recommended Answers

All 2 Replies

DLP/001/2013-2014
DLP/002/2013-2014
DLP/003/2013-2014

I don't recomended to make autonumber to an Id like this but you can split it.
Get the Last Invoice number from database and Split it by "/". Extract the second value in array and you will get the existing invoice num. Add it by 1 and there are new Invoice Num.
Ex :

Private Sub InvoiceNum()
    Set rs = New ADODB.Recordset
    ' Select last row data using MAX() function
    rs.Open "SELECT max(Id)from Address", Conn, adOpenDynamic, adLockBatchOptimistic

    Dim temp() As String
    temp = Split(rs.Fields(0), "/") 'Split data by "/" sign
    ' temp (0) will contain DLP
    ' temp (1) will contain 003
    ' temp (2) will contain 2013-2014

    MsgBox "DLP/00" & temp(1) + 1 & "/2013-2014" ' Show new invoice number 
    rs.Close
End Sub
commented: . +2
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.