After a while, if I turn the scroll / thumb wheel on my Pentax K-X, the setting jumped around. Looks like a case of dirty contact.
First you have to turned the camera on, because the flash won't pop up otherwise. Remove the 2 screws.
PS : Actually I forgot whether you need to remove both screws or just the A screw.
Update : This screw (screw A) is the only one that need to be removed. Thank you Henrdrik for the info
Remove screws A & B. Remove another screw on the other side of A screw as well. The A screws in my camera have coarser thread than the other. So it might be a good idea to keep them separate.
There is another screw in the battery compartment.
Carefully and slowly pry open the top plate. There are some wires connected. to it. Make sure not to pull it too far.
The encoder is attached to a plate by screws B. The plate is in turn attached to the top plate by screws A. Remove screws B, and the snap that hold the thumb wheel.
Be gentle with the snaps. They're quite fragile.
You might want (not necessary) to remove the plate so it is easier to access the encoder.
The snap on top is already opened
The contact is between PCB A and the wheel B. I use a needle, put 2 drops of naphta on it. Then rotate the wheel several times.
After this its a good idea to put the battery and test the wheel before reassembly.
Be careful not to drop the small detent ball inside ! (Thanks Erdos Zoltan for the input)
It might be a better idea to completely detach the top plate cables'. But I'm a bit wary of breaking these tiny connectors.