I second that. When I started to work for the company I now work for, I used to have the best idea during the five-minute walk to the next train station! Which is a good indicator that I haven't really been able to detach myself from the problem during the day.
I like to ask my coworkers as well. It often helps that most of them are not programmers; I have to explain the problem in a different way to them, which helps me to find the solution.
And I also like to go and have a cup of coffee. Not because of the coffee, but because it makes me get up and walk around. Then, I can just stay in the kitchen for a few minutes and think about my problem in a different environement.