3 Replies Latest reply on Jul 1, 2013 10:08 AM by philmodjunk

    Help with Script

    ChrisJones_1

      Title

      Help with Script

      Post

            

            

           Hi

            

           I wonder if someone can help me with a script I'm struggling with. I have got the script below to summarise the total amount of clients we transport between any given dates and to count the number of vehicles used to transport them using two Summary Fields in a table called Journeys. 

            

           The first summary field counts the vehicles used i.e minibus, DAR or a car and the second one just totals the amount of clients transported which is extracted from an input field on the journeys layout which is then displayed on another layout called 'clients transported' via a button on the journeys layout. 

            

           This works fine but what I'd like to do is summarise the amount of clients transported by vehicle type i.e 6 by DAR, 20 by minibus and 12 by car on the clients transported layout but I just can't work out how to do this so any help would be greatly appreciated.

            

      Show Custom Dialog [ Title: "Clients Transported"; Message:
           "Enter the Start and End Date for the month required in the search fields below."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No”; Input #1: Journey::gStart Date, "Start Date"; Input #2: Journey::gEnd Date, "End Date"; Input #3: Journey::Vehicle, "Specify Vehicle" ]

      If [ Get (LastMessageChoice) = 1 ]

      Enter Find Mode [ ]

      Set Field [ Journey::Start Date; Journey::gStart Date &"..."& Journey::gEnd Date ]

      Set Field [ Journey::Number Travelling; Journey::Vehicle = "Car" ]

      Set Error Capture [ On ]

      Perform Find [ ]

      Sort Records [ ] [ No dialog ]

      Go to Layout [ “Clients Transported” (Journey) ] 

      End If

      If [ Get (LastMessageChoice) = 2 ]
      Go to Layout [ “Journey” (Journey) ]

      End If

           Thanks in advance.

        • 1. Re: Help with Script
          philmodjunk

          Set Field [ Journey::Number Travelling; Journey::Vehicle = "Car" ]

               doesn't look correct. It will enter either a 1 (True) if the value in vehicle = "car" or 0 (False) if it does not. And since your window is in find mode the value entered will always be 0 unless Vehicle is a field with global storage.

               Do you have a record for each passenger that also indicates the vehicle type? If so, a summary report where a summary field counts the number of records and is placed in a sub summary part can count the number of passengers in each vehicle type if you sort your records by that vehicle type field so that the records are grouped by vehicle type.

          • 2. Re: Help with Script
            ChrisJones_1

                 Hi

                 You're right, it's not correct. I was playing around with the set field to see if I could get it to work so the "Car" shouldn't be there. 

                 In answer to your question, yes I do have a record for each passenger and the vehicle they travel in (albeit in seperate fields on journey layout).The summary report sounds just the thing I'm looking for though I'm not sure how to do this. Do I just add another summary field to my journey table to count the journey Ref number (record number) and if so how then do I add the sub summary part? Do I include the passenger field, vehicle type and passenger name when creating a report and then somehow get it to group them? 

                  

            • 3. Re: Help with Script
              philmodjunk

                   You may find this tutorial on summary reports helpful: Creating Filemaker Pro summary reports--Tutorial