THere are several ways to do this. One way is to use a calculation field in the equipment table that uses the Last function. Make the calculation field unstored. Another method is to define a relationship between your two tables where you specify a sorted relationship that sorts your repair records in descending order by a date field. Using that relationship, you can just place the "hours" field from the Repair table on your Equipment layout.
Yes, but why tax your system with an unnecessary calculation?
For small numbers of records--such as you might have while testing things in development, Max will work fine, but it will take more and more time to update as the number of related records increases. How many records you'd need before you see a noticeable delay will depend on a lot of factors, but we can, I think, avoid the whole issue by just accessing the value of the most recently added repair record for a given equipment record.
Not trying to hijack or disagree...Does Last depend on the related records being sorted correctly? Or does it go by creation order? I tried reading the knowledge base, but it is a little ambiguous to me.
Like any aggregate function, the relationship's sort order determines what records is First or Last so the relationship, not a portal's, sort order will affect what result is last. In an unsorted relationship, Last will return the most recently created related record where the field specified in the Last function is not empty.
That's why I made two recommendations:
- Sort the relationship and just refer to the field from the related record by putting that field directly on the parent record's layout. Doing this will reference the first related record.
- Don't sort the relationship and use Last( )
Please also note that I said: "I think". This is not something that I've tested or researched, but I'm assuming that these two methods are more efficient that using Max. Clearly, options 1 and 2 will also, to some degree, have performance affected by the number of related records so others more knowledgeable than I might chime in at any time and tell me that I'm wrong and in such case, I'll freely welcome the correction and learn something new.
This worked! i had trouble with it at first but found out it was the way my relationship was set up.
Thanks so much!