This is not as easy as it sounds. The ability to move the cursor to a new field is an AcroForm level command. When you add an instance of a subform the objects do not exist on the AcroForm side until the script is finished. In your case you want to mmove the cursor in the same script that will add the subform so the standard cursor reposition command will not work (as the new field dose not exist yet). There is an acroform command that will allow you to execute a command in the future (presumably when the script is finished and the objects actually exist). Unfortunately you must use the acrofom name to address the field. Here is a snippet of code that shows you the command that you need to use. Note that you will have to replace the object names with your own (the one that is between the single quotes):
var setField = app.setTimeOut("this.getField('form1.Page3.TextField4').setFocus();", 1);
I understand the concept (I think...), but am not clear on where to place the code.
I used Action Builder to create an AddSite action: when check box chkAddSite is checked | Add a new instance of subformSiteInfo | and set visibility of subformSiteInfo to visible. Does your code go in that same action sequence? If so, what is the next Action Builder result selection? If not, where do I insert it?
I never know whether the new instance of the subform will begin on the following page, so the user might keep clicking the chkAddSite box, thinking it didn't work. Although, thinking this through, maybe I could force the new subform instance to always appear at the top of the following page, and somehow direct the focus there, rather than to the specific first field???
I assume that you are activating the subform instance by clicking a button. The code would go on the click event of that button. There will be code there from the action builder so simply add it to the bottom of that script.
Your other idea wodul be fine. You coudl put a small 1pxel by 1 pixel field at the top of the page and simply set the focus to that field (it will already exist). Just make sure that you turn off the borders and captions and make the background and foreground color of the field the same as the background color of the form so that the field is not discernable by the user.
Hope that helps
Unfortunately, I am still having trouble with this.
My goal (see attached): When btnAddProgramInfo is clicked, add new instance of subProgramInfo at the top of next (new) page and set cursor focus to txtServiceProgName in the new instance.
The section before Program Information will be multiple/unknown number of pages
Each completed Program Information section could span several pages, and users could need to add as many as 20 programs. There is nothing following the Program Info section.
Sorry to be so dense, but I just can't seem to set the cursor focus in each new instance, no matter what I try.
Thanks in advance! ~Carol