4 Replies Latest reply on Jul 10, 2012 3:10 PM by philmodjunk

    Checkbox Values

    2859

      Title

      Checkbox Values

      Post

       I have a field called EmptySeats on a Layout.  This contains the Checkbox Set that I have defined in a Value List. When I check a box, all of the values go to the same Row in a table.  I tried to write a script to add a record to the table and enter the CheckBox Value - but it just adds a "0" on the line.  Is the checkbox value not the value that displays?

      My Script is:

      If [EmptySeats::SeatNo]

          Set Variable [$$Seat;value:EmptySeats:SeatNo]

          Go to Layout ["tblEmptySeats"]

          New Record/Request

          Set Field [EmptySeats:SeatNo;EmptySeats::SeatNo=$$Seat]

      End If

      It adds the record, but puts a "0" in the SeatNo field.

      What am I doing wrong?

        • 1. Re: Checkbox Values
          2859

           BTW, I'm using FileMaker v.12.

          • 2. Re: Checkbox Values
            philmodjunk

            Do you have more than one value in your check box's value list?

            Is the field of type text or number?

            Your post refers to "a field called EmptySeats", but your script does not refer to any field by that name. It refers to a table occurrence named emptySeats with a field named SetNo. Is that the checkbox formatted field?

            You indicate that "I have a field called EmptySeats on a Layout", What layout is that? If you open layout setup... for this layout, what do you have in "show records from"?

            This step:

            Set Field [EmptySeats:SeatNo;EmptySeats::SeatNo=$$Seat]

            Doesn't look right. It can only enter a zero into the SeatNo field. That's because you just created a new record and thus the SeatNo field for this new record is empty. The expression:

            EmptySeats::SeatNo=$$Seat

            Returns a 1 (True) if the value in $$Seat matches the value in SeatNo of the current record. If the values do not match, 0 (False) is entered into the field. Since this is a new field, SeatNo is empty; $$Seat is not and thus it always evaluates as False.

            You may need to try again here by describing your tables, layouts and the purpose of this script so that we can suggest a way to do what you need here.

            • 3. Re: Checkbox Values
              2859

               

              Do you have more than one value in your check box's value list?

              The value list has only a single value for each seat. I used a Custom Values List in order to get them to sort in the way I wanted, to simulate the layout of the seats (use of a Value list from a field resulted in only listing things alphbetical vertically).

              18-A   18-B   18-C   18-D  18-E

              19-A   19-B   19-C   19-D   19-E

              Is the field of type text or number? Text

              Your post refers to "a field called EmptySeats", but your script does not refer to any field by that name. It refers to a table occurrence named emptySeats with a field named SetNo. Is that the checkbox formatted field?

              It is a field called EmptySeats on a Performance Layout.  It is from a TABLE called EmptySeats that is related to the Performance TABLE by a PerformanceID field.  The Performance Table has the records that are shown on the Layout.

              You indicate that "I have a field called EmptySeats on a Layout", What layout is that? If you open layout setup... for this layout, what do you have in "show records from"?  Performance Table

              You may need to try again here by describing your tables, layouts and the purpose of this script so that we can suggest a way to do what you need here. I hope this helps.

              • 4. Re: Checkbox Values
                philmodjunk

                Yes but it's a check box field. This allows the user to select more than one value by clicking more than one checkbox. This could create issues for your database if only one value is permitted and since clicking more than one checkbox value in a check box set enters both values, separated by returns in the order the boxes were clicked, this can effect how you check to see what values are present in the field. If only one value is permitted in the field at a time, you might want to use radio buttons instead of check boxes.

                It is a field called EmptySeats on a Performance Layout

                To repeat, your script never refers to a field named EmptySeats. If you enter layout mode and click this field, what exactly do you see in "display data from" on the data tab in the inspector?

                Performance Table

                If your layout refers to a table occurrence named "Performance" and your script refers to fields in the EmptySeats table before changing to the layout based on empty seats, then this is a potential problem for your script that could keep it from working.

                When you open Manage | Dataase | Relationships, you should find two "boxes" (called table occurrences), one named "Performance" and one named "empty seats". What, if any, relationship exists between them. (You may want to upload a screen shot of this part of your relationships graph.)

                You may also find this tutorial on Table Occurrences helpful: Tutorial: What are Table Occurrences?