July 6, 200916 yr Hi, I am desperate to find some kind of a 'for each record' function but I can't find it anywhere. Ha anyone an idea how to to this? Thanks.
July 6, 200916 yr You might need to write a looping script. See the FM Help for Loop/End Loop. More info will get you better advice.
July 6, 200916 yr Author Great, thanks for the answer, I had never done any scripts in FM before, was not aware of the Loop function! I have tried it in the following but still have issues with the script. My first table, Sales Invoices, contains all the invoices, each of them with a field Job Number (each invoice is linked to a Job, there can be several invoices per Job Number). My second table, Job Numbers, contains all the jobs. In this table, I would like to add a field that gives the total amount invoiced per Job Number. I have named this field Total_Invoiced and set its value to Calculation '=$$Sum', ie the result of the below script. But nothing happens.... Set Variable [$$JN; Value:GetField (Job Numbers::Job Number)] Set Variable [$$Sum; Value:0] Go to Layout ["Sales Invoices" (Sales Invoices)] Go to Record/Request/Page [First] Loop If [sales Invoices::Job_Number = $$JN] Set Variable [$$Sum; Value:$$Sum + Sales Invoices::Amount USD Go to Record/Request/Page [Next; Exit after last] Else Go to Record/Request/Page [Next; Exit after last] End If End Loop Go to Layout [original layout] Thanks for your help!
July 6, 200916 yr You dont need a script for this... Create a new calculation field in the Job Numbers table. cTotalJob = Sum ( Sales Invoices::Amount USD )
July 6, 200916 yr And this post is a perfect example of why it is best to explain what you are trying to do, and let whoever responds offer the best technique.
July 6, 200916 yr While it's true that more information is usually better, a for each call IS explaining a lot (if one knows what for each means). Sometimes those coming from other languages don't know what to ask for except in their terminology. It can be a frustrating transition when reading FM Help and not seeing anything which even remotely fits - I know. :wink2:
July 8, 200916 yr Author Thanks for the answers @bcooney: the Sum() function solved all my problems, thanks a lot, no need for a script indeed. But good to know how to use the Loop function anyway. @LaRetta: glad you understand it is not always easy to discover a new language! Z.
Create an account or sign in to comment