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.

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#")

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.