+ Reply to Thread
Results 1 to 5 of 5

excel style formulas in query criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    11-09-2006
    Posts
    65

    excel style formulas in query criteria

    I have a query with 500k rows and use access and excel 2003.
    I want to move the data into excel but am limited with the amount of rows.

    To reduce the query amount below 65k rows I want to key on some criteria in 1 field.

    Anyway, I want to put a formula into the criteria to only select rows within a range of data. In excel I would sort using this simple formula:
    =IF(MID(P2,4,2)="45",MID(P2,4,2),"")
    Basically, pulling out 2 characters in the field and if they equal 45 then include that row.

    Is there some way in access to put similar formulas?

    I realize I could key on date or maybe some other criteria, but if I could get this work then it would satisfy some other needs as well.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: excel style formulas in query criteria

    There are a few ways you can approach your criteria.

    Try playing with one of these:
    WHERE MID([PartNum],4,2)="45"

    WHERE [PartNum] LIKE "???45*"

    WHERE LEFT([PartNum],4) LIKE "???45"


    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    11-09-2006
    Posts
    65

    Re: excel style formulas in query criteria

    Quote Originally Posted by Ron Coderre View Post
    There are a few ways you can approach your criteria.

    Try playing with one of these:
    WHERE MID([PartNum],4,2)="45"

    WHERE [PartNum] LIKE "???45*"

    WHERE LEFT([PartNum],4) LIKE "???45"


    Does that help?
    Thanks, I am getting error "invalid syntax" when entering as above. If there something missing?
    I am entering it into the design view - criteria field.

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: excel style formulas in query criteria

    Hi surfengine,

    It may be best to enter it in as a new field.

    In query design view, Field row:

    DataChop: Mid([PartNum],4,2)

    then in Criteria:

    45

    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  5. #5
    Registered User
    Join Date
    11-09-2006
    Posts
    65

    Re: excel style formulas in query criteria

    ahh, thank you. understood and working.
    Last edited by surfengine; 01-13-2010 at 06:39 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1