I am trying to get custom autonumber from a autonumber. But, when there is some data in the database table it runs smooth and when there is no data in database table it gives me error.
Private Sub CustomNo()
Dim comm As OleDbCommand
Dim commStr As String = "SELECT MAX(ID) FROM Table"
Dim RD As OleDbDataReader
Dim i As Integer
conn = New OleDbConnection(connStr)
conn.Open()
comm = New OleDbCommand(commStr, conn)
RD = comm.ExecuteReader
While RD.Read
If Not IsDBNull(RD.GetInt32(0)) = False Then
i = RD.GetInt32(0)
CustN = "ABC-" & i + 1
Custom_NoTextBox.Text = CustN
Exit While
Else
i = 0
CustN = "ABC-" & i + 1
Custom_NoTextBox.Text = CustN
End If
End While
conn.Close()
End Sub