thezed Posted July 6, 2009 Posted July 6, 2009 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.
bcooney Posted July 6, 2009 Posted July 6, 2009 You might need to write a looping script. See the FM Help for Loop/End Loop. More info will get you better advice.
thezed Posted July 6, 2009 Author Posted July 6, 2009 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!
mr_vodka Posted July 6, 2009 Posted July 6, 2009 You dont need a script for this... Create a new calculation field in the Job Numbers table. cTotalJob = Sum ( Sales Invoices::Amount USD )
bcooney Posted July 6, 2009 Posted July 6, 2009 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.
LaRetta Posted July 6, 2009 Posted July 6, 2009 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:
thezed Posted July 8, 2009 Author Posted July 8, 2009 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.
Recommended Posts
This topic is 5618 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now