Results 1 to 5 of 5
  1. #1
    EZRider is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    3

    Need to Remove Varying Middle Text

    I have a table that contains some game description [descrip] that includes description, model/version, and value all as a single text. I need a query that will "remove" the model/version and just return the description with the value.
    As the description may vary in length and number of words, I can't just use the Left and Right function. The common rules for what I need to remove are:
    1. Where the description contains a dollar sign ($) followed by any character other than a space:
      • If there is a space prior to the dollar sign I want to remove that space plus any other characters to the left of that space up to but not including the next space.
      • If there is no space prior to the dollar sign I want to remove the characters prior to the dollar sign and up to but not including the first space to the left.

    2. Here are some description examples where I have put in BOLD what I want the query to return and RED what I want the query to ignore.




    • GOLDEN GODDESS FAM14-93 $.02P
    • YOU BET YOUR A$ IPC12 $1P
    • MONO BONUS CITY BB519$.05P(LE)

    You'll notice that some of the descriptions also can include the dollar sign so it's important to destinguish that the "key" dollar sign is one without a trailing space (but rather a period or a number).

    If it's easier I could even live with the query just returning the left bolded parts (the description) and dropping both the model/version and the value.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Try:

    assume x = the field [descrip]

    model = Left(Trim(Left(x,InstrRev(x,"$")-1)),InstrRev(Trim(Left(x,InstRrev(x,"$")-1))," ")-1)

    value = Mid(x, InstrRev(x,"$"))
    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
    EZRider is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    3
    Thanks Super Moderator. It would appear to be doing what I'm looking for (I then joined to model and value to then make a single text field). I will check myself but just curious, is my second example (with a dollar sign that is part of the description) accounted for?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    That dollar sign has no bearing on the code I suggest.
    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
    EZRider is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    3
    Thanks again

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

Similar Threads

  1. Replies: 5
    Last Post: 08-23-2012, 11:20 AM
  2. Replies: 3
    Last Post: 05-29-2012, 04:47 PM
  3. remove unwrap text
    By jamesz in forum Access
    Replies: 11
    Last Post: 03-14-2012, 11:17 PM
  4. Replies: 3
    Last Post: 05-08-2011, 12:55 PM
  5. Extract text from middle of a field
    By AccessNubie in forum Access
    Replies: 3
    Last Post: 11-02-2009, 01:13 PM

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