0
Sub generate_inv()
Dim id_tmp As String
Query = "select top 1 InoviceNo from Invoice order by InoviceNo desc"
cmd = New OleDbCommand(query, cn)
dr = cmd.ExecuteReader
If dr.HasRows = False Then
dr.Close()
id_tmp = "E000001"
Else
dr.Read()
id_tmp = Format(Mid(dr("InoviceNo"), 2, 6) + 1,"E00000#")
End If
dr.Close()
txtInvoice.Text = id_tmp
End Sub

I use this code but some problem here, I con't understand what is the problem
Problem is : It is fine work blank database(means starting E000001) to E000009, after that showing the number E000011 after that no incensed the number. Please Help me.

2
Contributors
1
Reply
12
Views
1 Month
Discussion Span
Last Post by xrj
0

I think string should be converted in numeric, say
Format(CStr(Mid(dr, 2, 6)) + 1, "E00000#") or Format(CInt(Mid(dr, 2, 6)) + 1, "E00000#")

Edited by xrj

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.