UI focused?

I try to enter a value in text field.
It works, the text field seems to take the new value but in fact this new value is not stored.
It seems that I have to set the focused to true before changing the value but I can’t get this damn focused to switch to true !

my code

tell application “system events”
tell process “myapp”
tell window “theWindow”
etc, etc…
tell text field 1
set focused to true – error
set value to “test”
end tell
etc, etc…

any idea ?
I’ve tried set value to “test” & return too, but it seems that I really need to get this “focused” to work !

Perhaps you could supply us with a little more info about what you are trying to do.