Sometimes a 'crick' in the neck is because we lay in bed wrong. Take a look at your pillow. If it's too high, the body is usually laying at an unnatural angle. It might be worthwhile investing in one of those contour pillows. Too much computer and mouse usage could also be the culprit. Your computer screen needs to be at eye level.
Besides those things, a lot of the time for some reason, neck problems are related to stress/anxiousness. We sometimes unconciously hold our bodies, especially shoulders, neck (and our breath!) tight when we're feeling angry or defensive and feeling under attack and so the muscles go into a spasm and lock.
Take a look at - is someone in your experience being a 'pain in the neck' and/or have you felt under attack or rejected recently? A friend of mine got a crick in the neck within hours of going for a job interview and being told he was unsuccessful. He admitted to feeling the rejection and feeling defensive.
These cricks will usually go on their own as the tension/stress dissipates and your mind focuses on other things and I can see people have suggested hot showers and warm compresses which do help.
When you're doing either of those things, you're head will normally be tilting towards the painful area (so as to cause minimum pain). So, if the crick is on the left side of your neck, as the hot water is beating on the sore part, get the fingers and palm of your hand on the ok side of your body to gently pull the head towards the ok shoulder - a little at a time. This will pain a little but the pain will decrease with each movement. At the same time you are doing that, breath out and focus on dropping the shoulder on the sore side. Do the other side the same way.
Another thing that has worked with me was just to lay flat on your back on the floor for 10 minutes. Breathe deeply from the belly and concentrate on relaxing your shoulders. You can purposely make them drop. You can even do this simple thing if you're at work.