Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

zhed0708 (IS/IT--Management) (OP)
3 Sep 11 8:13
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..

zhed  

DougHennig (Programmer)
3 Sep 11 9:03
What do you mean "set filter without the table"? A filter is on a table so you can't set one without having the table open.

Doug
jrbbldr (Programmer)
3 Sep 11 14:20
LPARAMETERS tcFieldName, tcSearchText

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


 
danfreeman (Programmer)
4 Sep 11 2:09

Quote:

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.

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.
MikeLewis (Programmer)
4 Sep 11 4:17
My impression is that Zhed is looking for a generic way of setting a filter on any table. Rather than hard-coding the field name and the value, he wants to call a method which receives those items as parameters.

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

LPARAMETERS tcFieldName, tcSearchText, tcAlias
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
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close