Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOTable Filter

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
0
0
US
I have an ADOTable with multible fields. I need to filter on two fields, PayFor and PayYear, both string values. The filter values are:
PayFor = Reunion
PayYear = 2012

The following code does not work:

var
s: string;
t: string;
begin
With Form_Main.ADOTable5 do
begin
s := 'Reunion';
t := '2012';
Filter := 'PayFor = ' + QuotedStr(s) and PayYear = ' + QuotedStr(t);
Filtered := true;
 
Don't know if it's a typo, but the filter should be:
Code:
Filter   := 'PayFor = ' + QuotedStr(s)+' and PayYear = ' + QuotedStr(t);
 
Whenever I have problems with a SQL string, what I will do is build the string into a String variable before assigning the value of the variable to the SQL command or Filter. That way I can examine what exactly is being passed to the DB. Once I have the problem solved I will streamline the assignment directly to the property involved.
And Majlumbo is correct about the error in your filter statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top