Jump to content

Won't paste from Summary field to Global field


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

Recommended Posts

I got so excited about making zero records show in the global fields, now if there ARE records they won't show.

What in the world am I doing wrong?

I have tried this with the "Else" statement and without the "Else" statement, I can see the count being put into the Summary field but it refuses to be put into the Global field.

Here is one of the short scripts.

Show All Records

Enter Find Mode [Restore find requests]

Perform Find [Restore find requests]

Sort [Restore sort order]

If [status (CurrentFoundCount)=0]

Set Field [summary field, 0]

Go to Field [global field]

Paste [summary field]

Else

Perform Find [Restore find requests]

Go to Field [global field]

Paste [summary field]

End If

Like I said I have tried this with the "Else" statement and without the "Else" statement.

Link to comment
Share on other sites

Where do I start?

1) you can't set a summary field, Set Field [summary field, 0] doesn't do anything (if "summary field" is really of field type summary). The same is true for Paste[summary field].

2) forget copy and pastes. If you want to set a global field to zero, just use Set Field [global field, 0]

3) if you wish to use the value of a summary field, understand that it is context sensitive. The summary field value will be different depending upon where on a layout it is placed. In a subsummary part of a layout, it will reflect the selected aggregate (total, count, average, etc.) which is appropriate when that subsummary occurs. This is also dependent upon sort order. In a trailing grand summary part, a "total of" summary field will represent the total of all the records in the found set. Pasting a summary field to a global doesn't really do anything predictable (which value of the summary field is FM to use?). To extract the value of a summary field for use in a calculation, you must use the GetSummary() function. Which this function the summary field AND the break field must be specified (confusing, isn't it). GetSummary[summary field, summary field] will give you the aggregate of all the found records. GetSummary[summary field, break field] only gives predictable results when used in the definition of a calculation field placed in a subsummary part.

4) If you want to grab the total of a bunch of records and put the result in a global field, the Sum[] function is a much better bet BUT you must define a relationship which isolates the set of records you wish to work with.

5) Try:

Show All Records

Enter Find Mode [Restore find requests]

Perform Find [Restore find requests]

Sort [Restore sort order]

If [status (CurrentFoundCount)=0]

Set Field [global field, 0]

Else

Set Field [global field, GetSummary[summary field, summary field]

End If

You don't need a Go to Field to use a Set Field or to perform a second find Peform Find (restore). Also remember the only one set of "restore" conditions for a Find can be saved with each script. Both of your "Perform Find[restore] steps will always do the same thing.

-bd

Link to comment
Share on other sites

Thanks LiveOak,

Your solution works except now I have the same problem as yesterday.

To begin with I posted yesterday... "I’m putting together a series of scripts to do finds for various criteria. The end result is a bunch of summaries and calculations that go into a mess of global fields for storage to be exported for a scorecard. Everything works just wonderfully unless there are no records found for a specific search, at that point that field will show the previous find results. My problem is that I need to have “zero” or a blank field or the previous number erased when no records are found."

I was able to get my Global fields to store Zeros when no records were found but then the found counts wouldn’t show up.

I have put my summary fields in a subsummary part

I have put my calculation field in a subsummary part and rewrote the calculation to GetSummary[summary field, summary field] and do the rest of the calculation which I have set to become a percent. Since I have moved it refuses to show % and insists on having 3 digits after the decimal point (even though I set it to 0).

My global field still needs to store the found count and it doesn’t, or is there another way to store counts?

Link to comment
Share on other sites

I'm not completely sure of what you are trying to do, but I believe your problem is all implementation not FM limitations. If you put a calculation in a subsummary part that uses the GetSummary function, it must appear as GetSummary(summary field, break field). Break field must be replaced by the field name of the field that is used in defining "subsummary by xxx". Since you explicitly detect when no records are found, it should be an easy matter to set the global fields to zeros in such a case.

Global fields can clearly store found counts and display zeros when no records are found. We need to keep working on your implementation until everything works.

-bd

Link to comment
Share on other sites

The thing that I just don’t understand is...

When everything was working (except displaying zeros in the global fields), this is what the script looked like:

Show All Records

Enter Find Mode [Restore find requests]

Perform Find [Restore find requests]

Sort [Restore sort order]

Perform Find [Restore find requests]

Go to Field [global field]

Paste [summary field]

Pretty straight forward I thought, except the global fields would end up with the incorrect numbers when no records were found. (Another implementation issue I imagine?)

Then I put:

If [status (CurrentFoundCount)=0]

Set Field [global field, 0]

so zeros would replace the existing data stored in the global field.

That made zeros, but then wouldn’t allow existing records to show.

So I thought perhaps I’d put the else statement:

Else

Perform Find [Restore find requests]

Go to Field [global field]

Paste [summary field]

End If

Even though I did know the second “Perform Find” is ignored, I thought I’d give it a go anyway.

I am trying your latest instructions…

I have now rewrote the calculation to GetSummary(summary field, break field) and I get the same results… The global field does not change with records found or with no records found.

I don’t want to take up time with silly things, but it seems I’ve become a little anal on this.

Link to comment
Share on other sites

A couple of things with your script.

Show All Records

Enter Find Mode [Restore find requests] <--- This step is not needed

Perform Find [Restore find requests]

Sort [Restore sort order]

Perform Find [Restore find requests] <--- This step wipes out the first find and kills the sort order remove it

Go to Field [global field] <--- take this out

Paste [summary field] <--- use Set Field(global field, GetSummary(summary field, summary field) if you need a subsummary, this approach won't work.

The script as written will give unpredictable results.

I think your current difficulties setting globals are elsewhere. It's probably time to have someone look at your whole approach in person, not just in some pieces as they are presented in these messages.

-bd

Link to comment
Share on other sites

This topic is 7308 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.