How to get the correct key signature in repeat setting

I made a repeat section and in the 1,2 repeat the key is change. In the third repeat the key change also, but that is not good. How do i fix this. See the screenshot.

Welcome to the forum, Pieter. You’ll need to create a key change back to one sharp at bar 19.

Thank you for your help!