Dim total As Integer Dim t As Integer Dim connection As New OleDb.OleDbConnection(connStr) Dim updateOlebCommand As New OleDb.OleDbCommand 'get places left' counttable.Clear() sqlStr = "SELECT * FROM tblStudent WHERE OptionTaken = 'French Language'" dataadapter = New OleDb.OleDbDataAdapter(sqlStr, connStr) dataadapter.Fill(counttable) dataadapter.Dispose() 'good practice t = counttable.Rows.Count MessageBox.Show("the total is " & t) total = (30 - t) MessageBox.Show("the total is " & total) 'end of places' 'insert places' sqlStr = "UPDATE tblOption SET PlacesLeft='" & total & "' WHERE OPT = 'GamesProgramming'" connection.Open() updateOlebCommand.Connection = connection updateOlebCommand.CommandText = sqlStr dataadapter.UpdateCommand = updateOlebCommand dataadapter.UpdateCommand.ExecuteNonQuery() MessageBox.Show(sqlStr) connection.Close()