insertInstance() not working

Avatar

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

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

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.

Avatar

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