Add to a picklist dynamically?

Add to a picklist dynamically?

I have record Class with field Students, it is a picklist that looks up record Student

I need another form, that will dynamically add student to the Class, code something like this
  1. theStudent  =  Student  [ID == input.Student];
  2. theClass  =  Class  [Title == input.ClassName];
  3. theClass.Students.add(theStudent.ID);


This compiles with no errors, but it wont run or produce any results.