Private Sub GenerateID()
Dim sql As String = ""
Dim tmpID As Integer = 0
sql = "SELECT TOP 1 SaleID FROM Sale ORDER BY SaleID DESC"
Try
Com = New OleDbCommand
With Com
.CommandType = CommandType.Text
.CommandText = sql
.Connection = Conn
dr = .ExecuteReader()
dr.Read()
tmpID = CInt(CStr((dr.Item("SaleID"))))
tmpID = tmpID + 1
LastID = tmpID.ToString("0000000")
lblSaleID.Text = LastID
End With
Catch
LastID = "0000001"
lblSaleID.Text = LastID
End Try
dr.Close()
End Sub