When to use (who or whom) in written work.
Whom used to follow the rules of Latin grammar (nominative / accusative), so this is probably why it's confusing. Some still use when it in the latin way (put simply, for the inactive/receiving pronoun in a sentence), others just use it after prepositions and in certain 'instinctive' usages. The rules I follow are:
1) It is used after prepositions (though many people don't use this form when speaking anymore):
It went to Jim, by whom all applications must be approved.
It goes back to Darwin, through whom this theoretical advance was made possible.
There was the man for whom I'd voted.
To whom does this belong?
Of course these sentences were once seen as 'correct' - and it was a sin to put a preposition at the end of the sentence. Now it depends on the register you're using. These usages are especially common in formal writing.
2) It is used when the active subject (influencing the verb) follows the indirect person (whom):
She married the boy whom she'd befriended years before.
(boy is inactive)
It's Jenny that won; she's the one whom Jeff likes.
(jeff likes her, so she's inactive)
Whom did I beat at chess last Christmas?
(I beat him/her - so he/she is inactive)
Contrastingly, "who" takes the place of the active pronoun:
It was Jenny who gave you the T-shirt.
(Jenny gave it)
The award was given to Edison, who invented the lightbulb.
(Edison invented the lighbulb)
In short: ("who" + verb) (preposition + whom + verb) (... whom + active subject + verb)