I am fairly certain that Forty Years On has never been done on TV but it has been done twice on BBC Radio.
The first time with the original West End cast of John Gielgud as the headmaster plus Alan Bennett as Tempest and Paul Edington as Franklin.
The second more recent production was was in August 2006, this time with Bennett playing the headmaster and Robert Bathurst as Franklin. I think that this latter version is available on BBC audiotapes.