A significant challenge for in vivo imaging is to remove movement artifacts. These movements (typically due to either respiration and cardiac-related movement or surface chemical response) are normally limited to the axial direction, and hence features move in and out of the focal plane. This presents a real problem for high resolution optically sectioned imaging techniques such as confocal and multiphoton microscopy. To overcome this we have developed an actively locked focus-tracking system based around a deformable membrane mirror. This has a significant advantage over more conventional focus-tracking techniques where the microscope objective is dithered, since the active element is not in direct, or indirect, contact with the sample. To examine the operational limits and to demonstrate possible applications for this form of focus locking, sample oscillation and movement are simulated for two different biological applications. We were able to track focus over a 400 m range (limited by the range of the piezomounted objective) with a rms precision on the focal depth of 0.31 m±0.05 m.