Re: Forms 4.5 Running Totals

From: Tony Noble <cz0763%zip02_at_mt.gov>
Date: 1995/07/12
Message-ID: <3u0m0u$4k8_at_umt.umt.edu>#1/1


In article <950707090451_702420.204300_BHD54-29_at_CompuServe.COM>, Graeme_King_at_tjhouse.ccmail.compuserve.com says...
>
> Can anybody supply a solution to this problem?
>
> I have a multi-record block (displaying 5 records) based on a
 table,
> called for example EMP. The block has an item called SALARY in it.
>
> I want a text item (on a different block) which is a total of the
> SALARY column for all records queried (which may be one, many or
 all
> of the records in the table EMP).
>
> I tried a POST-QUERY trigger to calculate the total salary but it
 only
> fired 5 times i.e for each displayed record although there were
 more
> than 5 that meet the query criteria. When I scrolled down one
 record
> it fired again and updated the total salary. No good.
>
>
> Thanks in advance...
>
>
>
> Graeme King
> Information Systems Engineer
> Information Services
> Strathkelvin District Council
>
> email : graeme_king_at_tjhouse.ccmail.compuserve.com
>
I have a partial solution for you (I had to do this a few years ago for a time-keeping system). What you need to use are the built-in procedures, LAST_RECORD and FIRST_RECORD.

Last_record will force forms to finish retreiving all the records and your existing post-query trigger will handle the running total. First_record will cause forms to reposition the records so that it doesn't show that you navigated to the last record.

The tricky part, and the part that I can't remember exactly, is where to put the calls to last_record and first_record. These are restricted procedures, so you can't put them just anywhere. Also, you only want them to execute once. If I remember correctly I had a field where the user put in their social security number and then I had a key-next-field trigger that retrieved their time-keeping records. The last_record/first_record calls probably would go right after the execute_query call for the multi-line block. Anyway, a little experimentation should find a good place to place them.

I hope this helps,
Tony Noble
cz0763%zip02_at_mt.gov Received on Wed Jul 12 1995 - 00:00:00 CEST

Original text of this message