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!

Set filter to doesn't work ?

Status
Not open for further replies.

ChrizzA

Programmer
Jun 8, 2005
11
NL
Hello,

I've got a problem with the function "set filter to". I have a dataset which includes a date field. For some records this date field is filled, for other it's empty. Now i only want to show the records where this date field is empty, so i was thinking of doing this with a filter since i need the other records later on.

Currently i have something like this:

set filter to mydatefield == ctod('') in mytable

But this doesn't work for some reason because i still see records which have their datefield filled.

Can someone please help me with this ?

P.S. I allready searched here on this forum and with google but can't the right answer.
 
Try
Code:
set filter to empty(mydatefield)


Although I would not recommend a filter, but rather an SQL statement.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I've have tried your suggestion but the records with a date keep showing up in my dataset. Is there anything else i need to do ?

This dataset is filled using a sql statement, but i want to show the records on screen without a date and then use both in my report so i thought a filter would be a better idea than filling the dataset twice with sql. If i don't get this going quickly that is what i'm gonna do :)
 
I've have tried your suggestion but the records with a date keep showing up in my dataset.

Really? I cannot imagine why they would show up in your filtered data. Here is a test.

Code:
CREATE CURSOR mytable (date1 d)
APPEND BLANK
? EMPTY(date1)  &&& .T.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Personally, I'd go with Mike's SQL suggestion - filters can be pretty slow, especially with large datasets.

However, one thing to keep in mind with your filter scenario is that you have to move the record pointer after you set the filter for the filter to take effect. Just issue a LOCATE will move it to the first filtered record.

Regards,
Jim
 
After applying the filter and moving the record pointer with a locate, the records with a date are still there. If i enter your command in the command window like this:

Code:
? empty(mytable.mydatefield)

This returns .F. which offcourse is logical and thereby should not be present in my dataset when i set the filter.
 
Are you sure you have the correct table selected when setting the filter? Filters only apply to the currently selected table.
So if you set filter in one table, then select another, there will be no filter.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top