Results 1 to 4 of 4
  1. #1
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8

    Replacing query output based on multiple strings (Access 2013)

    Hello All,

    I am looking for a simple solution to replace output from my query.

    Here's the scenario:

    Table name: Sometable
    Field name: Sometext

    Existing query output with no replacement statement:

    Record 1: This output contains red
    Record 2: This output contains blue
    Record 3: This output contains green

    My Criteria: (I realize this is not correct syntax, but wanted to clearly define what I'm trying to achieve)

    If output contains "red", replace entire string with "10"
    If output contains "blue", replace entire string with "20"
    If output contains "green", replace entire string with "30"

    Expected output:

    Record 1: 10


    Record 2: 20
    Record 3: 30

    Thanks,

    Dave

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    NewOutputField: IIf(InStr(1,[Sometext],"red"),"10",IIf(InStr(1,[Sometext],"blue"),"20",IIf(InStr(1,[Sometext],"green"),"30")))

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Or:

    NewOutputField: Switch(InStr([Sometext],"red")>0,"10", InStr([Sometext],"blue")>0,"20", InStr([Sometext],"green")>0,"30")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8
    cyanide,
    Worked perfectly!
    Thanks!

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

Similar Threads

  1. Access 2013 Multiple Queries need to summarize
    By steffwood in forum Access
    Replies: 4
    Last Post: 01-07-2016, 03:42 PM
  2. Multiple regression in Access 2013
    By j235 in forum Queries
    Replies: 1
    Last Post: 11-17-2014, 02:23 PM
  3. Replies: 4
    Last Post: 12-30-2013, 05:51 PM
  4. Replies: 1
    Last Post: 09-16-2013, 04:35 PM
  5. Replies: 9
    Last Post: 03-16-2012, 11:13 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