A mechanism for preventing setting of a dose, which exceeds the amount of a medicament in a reservoir in an injection device. The device comprises a threaded piston rod, a limiter and a driver. The three elements are arranged such that during dose setting, the limiter is moved towards an end-of-contend position, wherein dose setting is limited. The invention comprises an accumulative and a non-accumulative embodiment. The invention further relates to a mechanism for prevention ejection of a dose exceeding the set dose.