Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Odd SET FILTER problem
Message
From
26/02/2004 16:47:36
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00881219
Message ID:
00881267
Views:
30
Hi Colin

You're headed for trouble.

1) It is much faster to not use objects/properties in Rushmore optimized statements like SQL and Filters.

This would be better.

LOCAL ldDate
ldDate = THISFORM.txtDateFilter.Value
SET FILTER TO Date = m.ldDate
LOCATE

2) Say you stick with your original code and launch a form from a button on your current form. If that second form has the DataSession property set to default, and in that second form, you try to move the record pointer in the grid's recordsource, it will crash because the property THISFORM.txtDateFilter.Value cannot be located. It will be out of scope. Even if it could be found, it would be slow. ;)

You could use the variable approach, but in the second form, or even in the first form, once the method that sets the filter ends, there will be a crash when the record pointer moves because m.ldDate has gone out of scope.

You can do this...

LOCAL lcDate
lcDate = TRANSFORM(THISFORM.txtDateFilter.Value,"@D")
SET FILTER TO &lcDate.

That way the filter will work, not matter what happens with the scope.

3) Grids and Filters are a potentially serious performance problem. The larger the table and the tighter the filter, the worse the performance.

You could use SET KEY, but if you want the user to have anything more than the simplest conditions or if you want them to resort the columns, you'll be much happier with parameterized views or even better creating cursors with SQL commands. The cursor can be indexed for as many sortable columns as you need. Additionally, the cursor only contains the records that met the user's criteria, so there is no filter.

Only thing is you'd have to give up on ever showing the user the entire table, which doesn't really work with large numbers of records, right?

HTH

>Hi Hilmar,
>
>Thanks for the quick reply. The .Value is {} and I even set the .Value = DATE() in the Form.Init.
>
>However, you're second suggestion was the issue. I changed SET FILTER TO Date = This.Value to SET FILTER TO Date = ThisForm.txtDateFilter.Value and now it works fine.
>
>Tx.
>
>>The type mismatch probably means that the date field is of type date, and the TextBox, of type character. Make sure it is of type date, or do a conversion. To make the TextBox of type date, you can assign it an initial value of {}.
>>
>>Also, "This.Value" will very likely be meaningless a little later in the program. Therefore, you may have to use a variable instead.
>>
>>HTH,
>>
>>Hilmar.
>>
>>>I have a form with a grid and a textbox. On the forms .Init the textbox .Value=DATE() and the table is filtered with, SET FILTER TO Date = DATE().
>>>
>>>In the .Valid of the textbox I have the following:
>>>
>>>SELECT Cmessage
>>>SET FILTER TO Date = This.Value
>>>
>>>ThisForm.GrdMain.Refresh
>>>
>>>When I type a valid date in the textbox like 2001.06.27 I get an Operator/Operand type mismatch error on the ThisForm.GrdMain.Refresh line.
>>>
>>>There is no code in the grids .Refresh event.
>>>
>>>Any thoughts?
Previous
Reply
Map
View

Click here to load this message in the networking platform