If you apply and then spend a lot of time in the sun, your vitamin production will be decreased, but not entirely. People who routinely apply sunblock spend more time in the sun, so they will end-up producing more than those who spend no time in the sun at all.
It's the cost of weighing burns against vitamin D production. The skin cancer worry (legitimate) due to sun damage vs. decreased vitamin D production is probably a good bet to make.