6 Replies Latest reply on Aug 24, 2011 9:31 AM by JLAFARGUE

    AddInstance not working-please Help


      I have been working on a form in Livecycle and have hit a brick wall. I have tried everything I know. I have the subforms marked as flowed and the repeating box on the binding saved. Also have saved it in a dynamic form. What I need is a every subform to have a simple add button on for a row but on the bottom I need the add button to be able to copy the entire table. I have read every post I can find and still nothing.


      https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0ByHqZuKg4V-OYzQ3NWUxNzE tYjMyYy00NmU0LTllNjUtMGViNGYxNjQ5MTI0&hl=en


      Here is the link to the file.


      Thank You,

      Mark Rhoudes


        • 1. Re: AddInstance not working-please Help
          pguerett Level 6

          There were two things wrong with your form.


          1. The code on the button to add an instance was incorrect. You want to replicate Table 3 so the syntax woudl be:




          2. Doing that generates an error indicating that the subform Table3 has reached the max number of instances. So go into the binding tab for the Table 3 object and set the "Reapeat Table ofr Each Data Item" checkbox on and you will be good to go.


          Note that you may need to re-arrange your form as you will find that once the first column breaks a page (i.e. bathroom) then you cannot go back a page and fill up the second column.


          Hope that helps


          • 2. Re: AddInstance not working-please Help
            mrhoudes1988 Level 1

            Now how do I get the total from the new boxes to add up together?

            • 3. Re: AddInstance not working-please Help
              pguerett Level 6

              Are you looking to total up the table for a room or are you looking to total all tables into one final total from all rooms?



              • 4. Re: AddInstance not working-please Help
                mrhoudes1988 Level 1

                Both. I know how to get the overall total but dont know the code to make it add in the total for the new rooms?

                • 5. Re: AddInstance not working-please Help
                  pguerett Level 6

                  This will involve some work ......you will need to name each of the rows in your table the same ...now you have it as row1, row2, row3 ......change it so that every row in the table has the same name (the product will add occurance numbers to make the fields unique). So if you named the rows Row then the result woudl be Row[0], Row[1], Row[2] ......note that you do not add the [x] the product will do it. Then you need to change the name of the Total field in each row to be the same I called mine Total. The occurances numbers will appear the same way as the rows.  Then create a formula to multiply quantity * Cost for each row. Now on your GrandTotal you can use a FormCalc calculation in the Calculate event of the Grand Total field. You can reference the Fields like this:



                  *].Total[*], Bathroom.Table3[*].Row[*].Total[*])


                  Note the use of the * in the occurance numbers ....this will reference every field with that structure so with a single statement we can add up all of the Totals from the General table and all Bathroom tables (note the * on the Table3 subform for when the user adds additional ones)....and as each row is completed the Grand Total will be calculated. You simply need to add an expression for each table you want to include in the GrandTotal calc ...sepearted by commas of course.


                  Lastly you should name all of your subforms ...it will make it easier when referencing objects in your Sum calculation.


                  I have modfied your previous sample to show you what I mean ( I did the General table and the Bathroom table only). See the attachment in this post.





                  • 6. Re: AddInstance not working-please Help
                    JLAFARGUE Level 1

                    Make sure that the settings in the Binding tab of the Object palette for the subform you are trying to duplicate are correct.  There is a checkbox labeled "Repeat Subform for Each Data Item".   Make sure that is checked.  It gets reset every time you make the page positioned.  If you have the Max checkbox checked, make sure there is a number > 1 in it.


                    The code to add an instance should look something like this in the click event of your add button: