set filter problem
set filter problem
(OP)
how to use set filter....
i have a code in set filter but in the presence on the table..
LPARAMETERS tcFieldName, tcSearchText
SET FILTER TO && clear any previous filters
SET FILTER TO ALLTRIM(UPPER(&tcFieldName)) = ALLTRIM(UPPER("&tcSearchText"))
GO top
thisform.refresh()
i want to use set filter without the table...thanx..
i have a code in set filter but in the presence on the table..
LPARAMETERS tcFieldName, tcSearchText
SET FILTER TO && clear any previous filters
SET FILTER TO ALLTRIM(UPPER(&tcFieldName)) = ALLTRIM(UPPER("&tcSearchText"))
GO top
thisform.refresh()
i want to use set filter without the table...thanx..
zhed
RE: set filter problem
Doug
RE: set filter problem
SET FILTER TO && clear any previous filters
SET FILTER TO ALLTRIM(UPPER(&tcFieldName)) = ALLTRIM(UPPER("&tcSearchText"))
GO top
thisform.refresh()
Doug - I too was originally confused since a Filter HAS to have a table to work on.
But then I saw that, even though it was not presented clearly, it looks as though zhed wants to create a Form Method that can be called against a variety of tables.
So the Filter would not be without a table, but instead the method would not specifically SELECT the table since that would have to be Selected BEFORE the Form Method was invoked.
zhed - so what is your question?
Unless you are getting a specific error message that we can advise you about, just get the method to work through your own efforts.
Don't look to us to just give you line-by-line code.
That is what you can hire a VFP contractor/consultant to do.
We are here to suggest/advise when people have questions or specific problems.
Good Luck,
JRB-Bldr
RE: set filter problem
Well if that's the case, the obvious answer is to add IN (alias) to the command (as well as the GO TOP) and be done with it.
But it's reading an awful lot into what hasn't been posted.
RE: set filter problem
If that's right, it's hard to see any benefit in this. It's surely just as easy to say SET FILTER TO x = y than thisform.SetFilter(x, y).
However, if you really do want a separate method to do this, Zhed, then you need to pass a third parameters, this being the alias of the table in question. The code would then be something like this:
CODE
SET FILTER TO ;
ALLTRIM(UPPER(&tcFieldName)) = ALLTRIM(UPPER("&tcSearchText")) ;
IN (tcAlias)
(By the way, you don't need to clear the previous filter. Issuing a new filter will automatically do that.)
But I really don't think this is a good way of going about things. It will limit your filter to a single "field = value" expression, plus it adds a level of obfuscation without any obvious benefit.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips, training, consultancy