Using command As New OleDb.OleDbCommand("SELECT Max(PIDTextbox) FROM Lap", con) con.Open() max_id = command.ExecuteScalar().ToString End Using