Ah, I see by Qazi's edit that the views aren't loaded at this point. You have your NewForm variable -- you might want to try adding a field to the form and then, in your code, set the value of the field. Set a rule on the field to switch views -- you can make that rule conditional, only set it when you open from code (thus, it has the value you set in your code), add a rule to clear the field after you switch the view. Not sure if it will work, but might be worth a try!