Your scripts look correct. If you have FileMaker Advanced, enable the script debugger and run this script to see if any script trigger performed scripts pop up and interfere.
The change to and from layouts can trip quite a few different triggers if they should be set on either of the two layouts involved here.
If you don't have advanced, you might try temporarily adding a bunch of show custom dialog steps to your script to both pause the script and display some text that tells you where you script is at each point where a custom dialog appears.
PS. The Show All Records step on line 3 is not needed, if you remove it, you'll get the same results as if you leave it in.