How to move Text Box to a new layer in QXP 6 or 7?

I’m a newbie in AS, and I have made a thorough serch on the forum but no luck to get an appropriate solution. So I need your help to advise me on my problem.
My objective is to move all the text boxes to a newly created layer in Quark.
My script looks like this:

tell application "QuarkXPress Passport"
	activate
	tell document 1
		make new layer at end with properties {name:"TextLayer"}
		repeat with p from 1 to count of pages
			set current page to page p
			tell page p
				repeat with t from 1 to count of text boxes
					move text box t to end of layer "TextLayer"
				end repeat
			end tell
		end repeat
	end tell
end tell

But when I execute the script with a document with 2 pages, 3 and 2 text boxes on the page 1 and page 2 respectively, I received a very strange result:
Not all my text boxes are moved over (only 1 from each page), and the worst part is one of the text boxes in page 1 disappear.
I need your help! Tks in advance!

I think what you are doing is breaking the reference to each text box once you have moved the first to a new location. What is usually easiest in these situations is to move your items in reverse order thus not breaking its index.

tell application "QuarkXPress"
	activate
	tell document 1
		make new layer at end with properties {name:"TextLayer"}
		repeat with p from 1 to count of pages
			set current page to page p
			tell page p
				repeat with t from (count of text boxes) to 1 by -1
					move text box t to end of layer "TextLayer"
				end repeat
			end tell
		end repeat
	end tell
end tell

Thank you so much for your prompt and wonderful reply, Mark67!
It works by reversing the order!
Sorry for my poor knowledge, I really cannot understand the logic behind. I would appreciate it if you could give me some tutorial on this (at your convenience). Thanks again!

Hi Mark67,
I tried your amended script at home and found it works great.
However, when I tried the same script on the other Mac in work place, the result is the same as my first post, i.e., not all text boxes are moved, the worst part is some text boxes just got disappear!
Any clues?
Thanks!