Subject Re: ApplyLocate error
From Mervyn Bick <invalid@invalid.invald>
Date Wed, 17 Jul 2019 09:28:21 +0200
Newsgroups dbase.getting-started

On 2019-07-17 2:23 AM, Ruth Bromer wrote:
> I have a program to create a table to be used to create a report for the
> shirt screener. (Mervyn wrote the original program with some
> modifications from me.)
>
> Since I have to add a few shirt orders that aren't coming from my input
> csv file, I am adding them to the input file and then resorting the
> output table (TShirtSorted.dbf).
>
> The original Screener.prg uses the table, Packet.dbf as input.  I want
> to use the TShirtSorted.dbf as input.  They both have the same relevant
> fields, shirt size and shirt color.  Most of the code is the same.


There is a far simpler way of getting the totals.  I can kick myself for
not doing this in the first place.


In packet.dbf the fields were tshirtsize,tshirtcolor and tshirtquant.

Instead of messing around building a new table I should have used the
following,


sql = "select tshirtsize,tshirtcolor,cast(sum(tshirtquant) as int) as
tshirtquant from packet where tshirtquant > 0 group by
tshrtsize,tshirtcolor order by tshirtsize"

Because I built a new table with the fields t_size,t_color and qty as
the fields these fieldnames are used in screener.rep


Replace the SQL in screener.rep with the following.  This will convert
the fieldnames in packet (or thsirtorders) table to the fields used in
the report.  Just change packet to whatever table you use.

sql = "select tshirtsize t_size, tshirtcolor t_color,
cast(sum(tshirtquant) as int) as qty from packet where tshirtquant >0
group by tshirtsize, tshirtcolor order by tshirtsize"

Mervyn.