The reversible photochemical E—Z-isomerization of crown-containing 4-styrylpyridine was studied. The reaction was carried out in the presence of alkaline-earth metals capable of forming complexes with the crown-ether fragment and heavy metal perchlorates (Hg2+, Cd2+) that are able to coordinate the nitrogen atom of the heterocyclic residue. The influence of complex formation on the E—Z-photoisomerization was determined by electronic spectroscopy and 1H NMR spectroscopy. The studies performed confirm that the E—Z-photoisomerization can be controlled using supramolecular complex formation.