Results 1 to 5 of 5
  1. #1
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228

    Criteria expression

    I want to make an expression field in an access query that takes a look at model numbers from another field, and determine what to write based on if it contains specific letters.



    Say my first column is model numbers, and my 2nd column is the expression, if the model number contains "k" I want the expression to show "Large", "j" would show "medium" and "d" would show "small".

    Model Number New Column

    21753j73 medium
    93757k42 large
    75831k84 large
    72837d78 small

    so on and so forth.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Try:
    NewColumn: IIf(Right([Model],1)="k","Large",IIf(Right([Model],1)="j","Medium",IIf(Right([Model],1)="d","Small","")))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Didn't come out right, I'll grab some actual model numbers. The actual criteria is if it contains Z -- output is 30, contains X -- output is 25, contains L -- output is 20, contains none of the above -- output is 15



    E250DHXSE 25
    E90DPLSE 20
    E300DCXSE 25

    and so on.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Hardly a surprize that it didn't work if the data and criteria supplied are wrong. Try:
    NewColumn: IIf(InStr(1,[Model],"z")>0,30,IIf(InStr(1,[Model],"x")>0,25,IIf(InStr(1,[Model],"L")>0,20,15)))
    This assumes that the column holding the model numbers is called Model.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Awesome, works perfectly! Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  2. Data Type mismatch in criteria expression
    By elb1999 in forum Queries
    Replies: 2
    Last Post: 01-20-2012, 02:38 PM
  3. datatype mismatch in criteria expression
    By CyberSkillsz in forum Access
    Replies: 1
    Last Post: 06-14-2011, 10:56 AM
  4. Criteria expression
    By benlw in forum Queries
    Replies: 1
    Last Post: 01-27-2011, 09:34 AM
  5. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums