If your values luck like "24-008765-T" - you have to take the number from the fourth character, not the second. It should be only 6 characters, not all of them as you have.
Mid(StudentNo, 2) <> Mid(StudentNo, 4, 6) ... :)
Mid() Function
Me.StudentNo = Right(Year(Date), 2) & "-" & _...