FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO-filter question
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
ADO-filter question
Posted: Mon Dec 10, 2012 07:59 AM
Hi,

Does anyone know how to put a filter on a recordset with a compare between 2 fields?

Those 2 filters are working fine
Code (fw): Select all Collapse
oRs1:filter:="minstock < 0"

Code (fw): Select all Collapse
oRs1:filter:="stock < 0"


but when I do
Code (fw): Select all Collapse
oRs1:filter:="stock < minstock"

I get an error

Just for testing, i tried oRs1:="0 > stock", and also have an error. Is it only possible to fut a fieldname a the left-site of a comparison?
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO-filter question
Posted: Mon Dec 10, 2012 08:59 AM

ADO filter method allows only one column name in the filter expression, as far as I know.

EMG

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: ADO-filter question
Posted: Mon Dec 10, 2012 09:02 AM

Enrico,

Thanks for the information. That's what I found out after searching for ADO-filters.
I guess I have to create a new recordset with a filter-condition.

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: ADO-filter question
Posted: Tue Dec 11, 2012 01:40 PM
Marc

Here is a sample of a common multi-field filter I use...

Rick Lipkin

Code (fw): Select all Collapse
cFilter1 := "[iid] like '"+cStockno1+"%' and [itype] like '"+cType2+"%'"
cFilter2 := "[d] like '%"+cDesc1+"%' and [itype] like '"+cType2+"%'"
cFilter3 := "[Bin] like '"+cBin1+"%' and [itype] like '"+cType2+"%'"

oRs:Filter := cFilter1+" and "+cFilter2+" and "+cFilter3
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: ADO-filter question
Posted: Tue Dec 11, 2012 02:06 PM
Rick,

I also use filters with multiple fields. But you can only compare a field with a fixed value and not with another field.

You can use
Code (fw): Select all Collapse
oRs:Filter := "Field1 = 0 AND Field2 = 0"
but not
Code (fw): Select all Collapse
oRs:Filter := "Field1 > Field2"
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion