ADO-filter question

ADO-filter question

Postby Marc Vanzegbroeck » Mon Dec 10, 2012 7: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: Select all  Expand view
oRs1:filter:="minstock < 0"

Code: Select all  Expand view
oRs1:filter:="stock < 0"


but when I do
Code: Select all  Expand view
oRs1:filter:="stock < minstock"

I get an error

Just for testing, i tried oRs1:filter:="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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: ADO-filter question

Postby Enrico Maria Giordano » Mon Dec 10, 2012 8:59 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ADO-filter question

Postby Marc Vanzegbroeck » Mon Dec 10, 2012 9: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: ADO-filter question

Postby Rick Lipkin » Tue Dec 11, 2012 1:40 pm

Marc

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

Rick Lipkin

Code: Select all  Expand view

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
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: ADO-filter question

Postby Marc Vanzegbroeck » Tue Dec 11, 2012 2: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: Select all  Expand view
oRs:Filter := "Field1 = 0 AND Field2 = 0"
but not
Code: Select all  Expand view
oRs:Filter := "Field1 > Field2"
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests