Jump to content

Help with script for total of records with exceptions


This topic is 5589 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi there,

I would consider myself a novice to intermediate FM user. I've been using it for 3 years now but have never been able to wrap my head around the whole scripting thing (I have absolutely zero experience with scripts/macros etc, so please keep that in mind when responding :( )

Here's my problem... I would like to have a field that tells me the number of records, in the found set, that have a particular phrase in a certain field.

For example:

The field called "First Name" has multiple records with people with name "Bill". I'd like the field "total of Bills" obviously, to show the total number of Bill's there are.

This is my script so far:

If [First Name = "Bill"]

Insert Calculated Result [Total of Bills; Count ( First Name)

End If

Should I have it looping so that it cycles through all the records, or does it do that automatically?

I'm sure this is probably really simple, and that I'm way off. Any help is much appreciated!

Kallain

Link to comment
Share on other sites

There would be at least a couple different approaches to this. But the Loop is a good one for the found set. I'm assuming this is a temporary total, for that reason. In which case the Total of Bills field should be a Number field, with global storage; so it is accessible from every record. Yes, you need a Loop. Pseudo code:

Freeze Window

View As Form <- makes loops faster

Set Field [ Total of Bills; 0 ]

Go to Record [ First ]

Loop

    If [First Name = "Bill"]

        Set Field [ Total of Bills; Total of Bills + 1 ]

    End If

    Go To Record [ Next; Exit after last ]

End Loop

Go to Record [ First ]

View As List

Edited by Guest
Forgot the End Loop!
Link to comment
Share on other sites

  • Newbies

Thank you for your help Fenton. I tried what you suggested, unfortunately, it's only returning a result of 1, even though there are mutliple bills.

I have the field "total of Bills" in a trailing grand summary part. Could this be messing things up?

Thanks,

Kallain

Link to comment
Share on other sites

This topic is 5589 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.