okay... i have no idea what you're designing so let's name and define, for the purposes of the exercise, a few parts.
firstly, the BASE, which is just a block with a hole, the SHAFT, which is (would you believe it) and shaft, and GEAR1 and GEAR2, which are two shapes, with holes in them, that you want to independently spin on the shaft.
Okay, first, we constrain the SHAFT into the BASE. With the constraint dialogue set to *MATE*, select the axis of the shaft, and then the axis of the hole in the BASE. Then press okay. If you exit the constraint command you should now be able to drag the shaft in and out through the BASE (but keep your thoughts clean!!)
Next, to stop it from sliding, start the constraint dialogue, set it to *FLUSH*, and pick the flat face at end of the shaft, and a flat face on the base to make it flush with. And press okay.
Now, what we've done to the shaft is remove five degrees of freedom. it cannot translate in any direction, only rotate about it's axis. You now have to apply those same constraints to each of the GEARs to locate them on that shaft. So, use a MATE constraint from the axis of the gear to the axis of the shaft, and then either a FLUSH or MATE from a flat face on the gear to a flat face on the base to set the location along the shaft you want. IF you're using more than two constraints, (the axis mate, and either a flush or mate on a face) you've done something wrong.
HTH.