Results 1 to 7 of 7
  1. #1
    tmccasland is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2018
    Posts
    3

    I need an if then formula in Access

    So I have an excel sheet with a complicated if then formula that I have tried to make work in access but it wont sadly. So with help we as in he has done most of it for me. We have hit a snag though. I need one column to pull letters out of another column and assign them numerical value. For example "w" is "5", "gs" is "3", "c" is "2", and "ru" is "1". in my excel sheet I could only put one of each numerical value. In Access I would like it to be infinite. No matter how many "w's" it is "5" per. can anyone help me with this dilemma.
    thank you in advance

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Are there only those 4 alpha patterns? What happened to number 4?

    Perhaps nested Replace()

    Replace(Replace(Replace(Replace([fieldname], "w", 5), "gs", 3), "c", 2), "ru", 1)

    If you need more help, show example data and desired result.
    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.

  3. #3
    tmccasland is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2018
    Posts
    3
    Thank you so much that worked great, it turned our w into 5 etc. Unfortunately one step forward and one back. If I have more than one reward such as W W it returns 5 5 instead of 10 in the box. Is there an easy way to turn multiple numbers in one field into a total sum number? 5 4 1 into 10. Thank you

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    With VBA custom function.
    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.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    it is not clear to me exactly what your reward string looks like but this will add your values together

    ?eval(Replace(Replace(Replace(Replace("wwgsru", "w", "+5"), "gs", "+3"), "c", "+2"), "ru", "+1"))
    14

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    tmccasland,

    How about showing readers some sample "patterns", and
    your desired output from these?

    It would be easier to assist/advise you, if you would provide some sample data (input and expected output).

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Ahh, I forgot about Eval() function, nice!
    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.

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

Similar Threads

  1. Access Formula
    By mike182 in forum Database Design
    Replies: 3
    Last Post: 12-03-2016, 12:31 PM
  2. Access Min Formula Help
    By Jmaes1994 in forum Database Design
    Replies: 4
    Last Post: 11-04-2016, 11:40 PM
  3. Replies: 19
    Last Post: 07-13-2015, 10:15 AM
  4. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  5. Formula In Access
    By kamkikorich77 in forum Access
    Replies: 5
    Last Post: 11-15-2014, 11:37 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