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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with filtering in code

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
Strange problem with Filtering.
I have created an integer variable, Today, in the format YYYYMMDD. I then read a variable from an ADOTable, ExpYearMonDay, in the same format. I then have the following code:

ExpYearMonDay := Form_Main.ADOTable1.FieldByName('ExpYearMonDay').AsInteger;
Form_Main.ADOTable1.Filter := 'ExpYearMonDay >= Today';
Form_Main.ADOTable1.Filtered := true;

This fails. After The Filtered line the remainder of the code in the procedure is skipped. If I replace the Today interger value with 20101217, today’s date, the code works.
Both variables are declared as integers.

What is my problem and what is the solution

I an running Delphi 7 on a Windows 7 machine.
 
Code:
Form_Main.ADOTable1.Filter   := IntToStr(ExpYearMonDay)+' >= ' + formatdatetime('yyyymmdd',Date);
 
Sorry - I didn't see that your Today variable was already in the metric date format:

Code:
Form_Main.ADOTable1.Filter   := IntToStr(ExpYearMonDay)+' >= ' + IntToStr(Today);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top