Private Sub CmdAdd_Click()
term = Me.CmbClass.Value
If Me.Rw2.Text = "" Then
MsgBox "Fill the the name box!", vbInformation, "Slimsoft System"
Exit Sub
End If
If Application.CountIf(Sheets(term).Range("C7:C1007"), Me.Rw2.Text) > 0 Then
MsgBox "The name " & Me.Rw2.Text & " already exists", vbInformation, "Slimsoft Systems"
Exit Sub
End If
With Sheets(term)
Set Drng = .Range("B7")
Set lrRng = .Cells(.Rows.Count, Drng.Column).End(xlUp).Offset(1, 0)
lrRng.Value = Application.Max(Range(Drng, lrRng.Offset(-1, 0))) + 1
For i = 1 To 24
lrRng.Offset(0, i).Value = Me.Controls("Rw" & i + 1).Value
Next i
If Me.Rw26.Value <> vbNullString Then
lrRng.Offset(0, 25).Value = CDate(Me.Rw26.Value)
Else
lrRng.Offset(0, 25).Value = Me.Rw26.Value
End If
lrRng.Offset(0, 26).Value = Me.Rw27.Value
Me.Rw2.SetFocus
Dim vLastName As String
With Worksheets(term)
vLastName = .Cells(.Rows.Count, "C").End(xlUp).Value
End With
Call SortIt
Me.OptClear.Value = False
Me.OptSearch.Value = False
Call LookupCurrentName
With Me.lstView
'.ListIndex = Application.Match(vLastName, Application.Index(.List, 0, 2), 0) - 1
End With
For i = 1 To 27
Me.Controls("Rw" & i).Value = ""
Next i
Call Switch_Controls
End With
End Sub