What happens if installed Medium is trashed during access on R&D?
From the FAQ:


  When the Runner chooses to access cards in a server he or she will access a set number of cards. Upon choosing to access, that number is determined by the total number of cards a successful run on that server would normally access, any active modifiers that may be adding to or reducing the number, up to the number of cards actually in the server, plus all cards in a central server’s root.


This doesn't go on to address Medium specifically, but as you suggested, the number of cards accessed is determined at the moment of choosing to access. Therefore Medium would let you access the 3 cards, even if Sapper ends up trashing Medium.