In general, affect is a verb and effect is a noun. I use a mnemonic device: a comes before e in the alphabet, and you can “affect an effect.” In other words you can verb (action) do something to achieve a thing (noun).
Confusing the issue is that effect can be a verb but it means to make something happen. The mnemonic device here this that affect means slightly change and effect means absolutely affect. If you effect change, the change has happened.