Subject Re: Filter problem
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 29 Mar 2025 09:29:03 +0200
Newsgroups dbase.getting-started

On 2025/03/28 23:05, Charlie wrote:
> I am having a problem filtering this.  I've tried different attempts including params with no luck.
>
> sql
>     this.COLLECTION6 = new QUERY(this)
>     with (this.COLLECTION6)
>        left = 448.0
>        width = 64.0
>        height = 37.0
>        database = form.coindata1
>        sql = "SELECT SUM(qty * estv) AS catval FROM COLLECTION"
>        active = true
>     endwith
>
> variable:
> fltr = trim(form.category1.rowset.fields["cat"].value)
>
> one of several attempts at a filter:
> form.collection6.rowset.filter = [category ='] + fltr + [']
> form.entryfield6.value = form.collection6.rowset.fields["catval"].value
>
> This gives me 'undefined: category'
>
> Any help would be appreciated!
>

As Heinze has pointed out, category isn't in the rowset so you can't use
it in your filter.

Try the following.


sql = "SELECT category,SUM(qty * estv) AS catval FROM COLLECTION GROUP
BY category"

This will give you a rowset containing the fields category and catval
and you can filter the field category to get the value in the
corresponding  catval field.

If you use a GROUP BY clause you have to include all non-calculated
fields in the field list in the GROUP BY.


Mervyn.