0

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?

2
Contributors
2
Replies
25
Views
3 Years
Discussion Span
Last Post by subrata.roy.7583992
1

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
Votes + Comments
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.