4 Replies Latest reply on Apr 30, 2012 9:15 AM by disabled_JackRodgers

    Adding to a repeating field by calculation

      Title

      Adding to a repeating field by calculation

      Post

      How can I get a calculation to ADD to the bottom of a repeating field. 

      I have UN-checked "select entire contents on entry" but all the data gets replaced by the calculation. 

      In other words, the calc should just add it's data to the next line without erasing/replacing the data already there.

       

      Thanx to all who reply.

        • 1. Re: Adding to a repeating field by calculation

          First you need to know how many cells exist in the repeating field. There is a function that returns that value.

          Next you simply set field (thefield[nbr0fcells+1])

          THIS IS INCORRECT BUT I AM LEAVING IT WHILE CORRECTING IT BELOW. (I've used too many database applications...)

          • 2. Re: Adding to a repeating field by calculation

            Does "set field (thefield[nbr0fcells+1])" take into account items already in the field?

            Lets say I have 4 items in a 10 field list... Will this calculation put data into the 5th position?

            Also, I guess when an item gets deleted, the lower repeating fields will move up...

            Thanx.

            • 3. Re: Adding to a repeating field by calculation
              philmodjunk

              It sounds like you should be using either a non repeating mult-line text field or a portal of related records for this.

              Set field can append text to the end of a list of return separated values in that non repeating field if you use the list function like this:

              Set Field [YourTable::TextField ; List ( YourTable::TextField ; "NewValueHere" ) ]

              And if you use a portal with a related table of records, you can add a new related record in the portal's table to append data to the end.

              In both cases, deleting an existing value or related record will enable existing values to "slide up"--which won't happen with a repeating field.

              • 4. Re: Adding to a repeating field by calculation

                As penance for my error I have added a blog page elaborating on the nature of repeating fields: http://wp.me/1AmGx

                Since you define the number of repeating cells in the field in the database manager that number of cells will always exist. You cannot increase the number of cells using a script so if you need to add a cell you have to add it in the database manager field definition dialog.

                To put the value in the fith position you use set field thefield[5]. The value in the bracket is used to define which cell you want to use.

                Click on the field name to insert it into the calculation area and then type the [x] after the field name.

                In your example you have the options:

                fieldname[1]
                fieldname[2]
                ...
                fieldname[10]

                Data does NOT move if you set a cell to empty. You do not delete the cell, you delete the data in the cell. The cell continues to exist and the other cells are not affected when you set another cell to empty. A similar action occurs in a spread sheet where you delete the data in one cell but not any any other.

                Set field fieldname[4] to ""