Results 1 to 7 of 7
  1. #1
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143

    update field value

    I have one field called results with values 'Res Positive', 'Res Negative' and 'Invalid'. When I run this query to update another table I want to just take 'Positive', 'Negative'and 'Invalid'. that mean I need to remove 'Res' if the result is Positive or Negative and read any other value as is.


    It should be straight forward but not working for me.


    Thank you

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Use Mid([Result],Instr([Result]," ")).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143
    This mid function is only working for 'Res Positive' and 'Res Negative' values. If the result field has Invalid or repeat this function is give me #Func!.
    How to resolve this?

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    Using Vlad's formula, I changed it to
    Code:
    IIF(Instr([Result]," "),Mid([Result],Instr([Result]," ")+1),[Result])
    I added the +1 to remove the space after "Res"

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Hi Steve,
    Shouldn't it be IIF(Instr([Result]," ")>0,Mid([Result],Instr([Result]," ")+1),[Result])?
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would work both ways. The syntax of the IIF() function is IIf(expr, truepart, falsepart)

    The expr MUST evaluate to TRUE or FALSE.
    FALSE equals Zero and TRUE is Not False. So any numeric value that is Not False (ie not 0) is True.

    0 = False
    1 = True
    100 = True

    If you search for a space in the field "Result" (the expr) and there is not a space, then a Zero is returned, so use the FALSE part, which is [Result].
    If a space IS found, in this case it is the 4th character, so it result is True (Not False). Therefore use the TRUE part expression -> Mid([Result],Instr([Result]," ")+1).

  7. #7
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143
    Thank you Vlad and Steve. Works both ways with or without >0.
    You guys are awesome

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

Similar Threads

  1. UPDATE 3073 error trying to update a table field
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 10-11-2018, 05:11 PM
  2. Replies: 4
    Last Post: 03-27-2018, 09:19 PM
  3. Replies: 1
    Last Post: 03-11-2018, 11:44 AM
  4. Replies: 1
    Last Post: 10-27-2016, 12:14 PM
  5. Replies: 2
    Last Post: 08-30-2012, 07:59 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