Results 1 to 7 of 7

Thread: [RESOLVED] Filtering a column in a Query

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved [RESOLVED] Filtering a column in a Query

    Which method has to be used in order to add a filter to a query's column?
    Last edited by Fonty; May 8th, 2007 at 07:54 AM.

  2. #2
    Hyperactive Member Foxer's Avatar
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    278

    Re: Filtering a column in a Query

    More information please. What program/version/query?
    Rate my response if I helped

    Go Hard Or Go Home


  3. #3

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Filtering a column in a Query

    I have a query in Access which generates a set of 4 fields permutations in a table (let's say PER).
    One of the fields (let's say FIELD_X)can take only 6 values (let's say VAL1,...VAL5, VAL6)
    I would like to have a macro which could, open the query, add a filter to FIELD_X, then run the query for VAL1 filtered, creat table PER_VAL1, then the same for VAL2... etc. In the end I should have 6 tables.

  4. #4
    Hyperactive Member Foxer's Avatar
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    278

    Re: Filtering a column in a Query

    If you were using MS Access code then you would just modify the query at run timel

    db.execute "Select * from PER where FIELD_1 = 'somevalue';"
    db.execute "Select * from PER where FIELD_2 = 'somevalue';"


    You coud do that in a loop or as many times as you like.

    If you're not using code then you would add a parameter to your query. In the query designer for MS Access you would set up a parameter so that MS Access prompts you for a value at runtime and then filters against that value.
    Rate my response if I helped

    Go Hard Or Go Home


  5. #5

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Filtering a column in a Query

    I'm getting run-time error 3065, which says I cannot execute a Select Query. My query is a Select Query type. How could I correct this?

  6. #6
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Filtering a column in a Query

    Code:
    docmd.runSql "Select * Into  PER_VAL1 from PER where FIELD_2 = 'val1';"
    ........

    Hope it will resolves the problem
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  7. #7

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Filtering a column in a Query

    Perfect. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width