Highlighted

insertInstance() not working

Avatar

Guest

05-11-2008

I have a form which can add continuation pages to several fields. I initially have all of the continuation pages presence set as "hidden" with a button/check box to add another page using insertInstance(). For some reason insertInstance() is not working. It does work fine if the pages are initially "visible". Any ideas as to why this wouldn't work? Here is the code I'm using:



var i = Page20.instanceIndex + 1;

Page20.instanceManager.insertInstance(i, 0);

Replies

Highlighted

pguerett

05-11-2008

If the subform is hidden then it does not really exist in the layout and any reference to that object cannot be resolved. If there is at least one instance of the object then your syntax will work (like when you make it visible). There was a syntax created to communicate with the instance manager to allow you to add an instance when a base object does not exist yet. To do this use the syntax below:



_Page20.insertInsatnce(i,0);



The underscore (_) indiicates that you are communicating with the named subforms instance manager.
Highlighted

Avatar

Guest

05-11-2008

Thanks Paul, that helped.

I think also when you create an instance of a subform that was originally "hidden" from the layout the new instance starts out that way.

I was able to work around that by converting i to a string, creating a variable set as Concat("Page20[", i, "]"), and then setting the presence of that to "visible".



Thanks again,

Ian Hockett