Last 7 days script

I want to create a button.

I have a field that i want to see the total hours that student has spent flying.

Each training session will accumulate hours flown.
I want to clock a button to show the total hours the student has flown..

can somebody help me out with this?

Welcome to The Soup @ClarisUSER. I hope The Soup becomes a valuable FileMaker resource for you.

I assume you operate a flight school. I also assume your solution has a student table and a training session table. You can create a field in the student table that sums the hours flown field of the training session table.

There is no need for a button, unless I misunderstood your request.

Hope this helps.

1 Like

The normal "FileMaker" way of doing this would not involve scripting or a button at all.

You would have two Tables, a users table and a flights table.
The flights table would be a list of flights (with some sort of field that indicated the # of training hours, e.g. "FlightHours")

The two tables would be related by an ID field (probably Student ID).

You then create a Calculated field in the users table which has a formula something like this:

TotalFlightHours = Sum(Flights::FlightHours)

No need for a button or script.

[Edit to add: seems like bdbd and I came up with basically the same solution. The FileMaker Force is strong here]

[Edit 2: your title is "last 7 days". If you wanted to limit this calculation to only flights in the past week, you could do this a few ways. One way would be to create a relationship between the two tables that uses the < and > relationship operators, e.g. a relationship where:

  • Student::ID = Flights::StudentID
  • today >= Flights::dateOfFLight
  • weekAgo < Flights::dateOfFlight

where Today and WeekAgo are calculated fields.

1 Like

The customer is specifically asking for a script/button so the system doesn't think or slow down ... reloading when clicking between portals etc

I forgot to add i want to have 14 days 30 days 90 days and 180 days.... i have the fields in the tables but to be updated once i press the button

Then it's a classic case of running a bunch of finds in the training session table to compute the numbers. If the fields that will display the results are not in the same table, you will need to store the results temporarily in variables or globals fields.

1 Like