Research has shown that sunscreen helps prevent squamous cell carcinoma, but has no effect in preventing basal cell carcinoma. For melanoma, research has been contradictory. Some research shows that sunscreen prevents melanoma, while other research shows that it increases your chance of getting melanoma.
For these reasons, the Vitamin D Council believes that covering up with clothing and/or going into the shade (after you get a little bit of sun exposure), is a safer way to protect yourself from too much sun exposure.
Another alternative is to use a non-nano barrier sunscreen after you have gotten enough sun exposure for Vitamin D production.