With "a". "Para" is used to explain activities that are not known by the other person or activities that are not normally associated with the place:
Tuve que ir a la verdulería a comprar papas.
Tuve que ir a la verdulería para solucionar una filtración.
Also "a" is used with "complete" activities, like buying potatoes, and "para" when the action is a part of a greater item:
Tengo que ir a la casa central del banco para terminar el trámite del préstamo.
Use "para" when you refer to activities done by others and linked with the conjunction "que":
Tendré que ir al registro para que me extiendan el permiso por 30 días más.
Rule of thumb: use "a" with well known, complete activities and "para" with all that requires an explanation or shows others performing tasks (the sentence "tuve que ir al dentista a que me arreglara ..." usually is ended by "...una
carie"
)