Hi there. Please help me, i am currently making a program right now. Flexgrid is not working properly and i can not figure out how it happened.

The following are the objects i have in the program: Name (txtName), Student Number (txtStudNo), Add (cmdAdd), Remove (cmdRemove) and FlexGrid (flxCart)

The following are the codes for Add and Remove
--------------------------------------------------------------------------
Private Sub cmdAdd_Click()
Dim ctr As Integer
ctr = 1

While ctr < flxCart.Rows
If flxCart.TextMatrix(ctr, 2) = txtStudNo.Text Then
Exit Sub
End If
ctr = ctr + 1
Wend

flxCart.Refresh
If flxCart.TextMatrix(1, 1) = "" Then
flxCart.TextMatrix(flxCart.Rows - 1, 1) = txtName.Text
flxCart.TextMatrix(flxCart.Rows - 1, 2) = txtStudNo.Text
ElseIf flxCart.TextMatrix(1, 1) <> "" Then
flxCart.Rows = flxCart.Rows + 1
flxCart.TextMatrix(flxCart.Rows - 1, 1) = txtName.Text
flxCart.TextMatrix(flxCart.Rows - 1, 2) = txtStudNo.Text
End If
End Sub
-----------------------------------------------------------------------------------------------

Private Sub cmdRemove_Click()
Dim ans As String

If flxCart.TextMatrix(flxCart.RowSel, flxCart.ColSel) <> "" Then
ans = MsgBox("Are you sure you want to delete this reserve records?", vbYesNo, "Library System")
If ans = vbYes And flxCart.Rows = 2 Then
flxCart.TextMatrix(1, 1) = ""
flxCart.TextMatrix(1, 2) = ""
ElseIf ans = vbYes And flxCart.Rows > 2 Then
flxCart.TextMatrix(flxCart.RowSel, 1) = ""
flxCart.TextMatrix(flxCart.RowSel, 2) = ""
flxCart.RemoveItem (flxCart.Row)
End If
End If

End Sub
-----------------------------------------------------------------------------------------------

*flxCart will display Name and Student Number when the user clicks the cmdAdd.
*Same Student Number will not be added to the flxCart.
*Once the cmdRemove is click the selected row from the flxCart will be deleted.

Problem:

During RUN TIME, assuming I added four(data) to the flexcart (Stud1, Stud2, Stud3, Stud4).
Then I remove Stud3 to the flxCart. But when i click the cmdAdd for adding the previously deleted record(Stud3) again. The codes for cmdAdd is not working.

Please help me... thank you.