Results 1 to 7 of 7
  1. #1
    rudeamy is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    4

    Exclamation Selecting data between two sets of characters

    Hi All:

    This is my first post...

    I need to extract data (that is different in all cases, see below) from between two sets of data that appear anywhere within a single field and copy it to another field.

    For example, I have a field called SecondLine and here is the full data value for three of its records:

    Hello my name is Rudeamy and I love the color orange.
    Hey everyone, my name is Fred and I love the color red, but I also like purple.
    Howdy, my name is Julia and I love the color lavender.


    I need the data between "my name is" and "color" to appear in another field, called FirstLine.



    (This isn't really the data I need to extract, but I think its an appropriate substitution.)

    Any suggestions are greatly appreciated.

    Amy

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You may wish to research

    Instr() and Mid () functions in Access

    http://www.techonthenet.com may have info

  3. #3
    rudeamy is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    4
    Won't instr() just give me a numeric position of the characters I need? I've tried mid()-- (at least at the basic level)--and that doesn't seem to be working. I'm guessing this involves building a Module, which I'm not equipped to do. . .

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Yes, you're right

    Instr(...) gives you a position where a string A starts, say X
    and Instr(xxxx) gives you the position of where the second string starts, say Y

    So if you know where the strings X and Y start, You could extract the string between X and Y, and adjust for the length of the "marker string you searched for", to a field of your choice.

    If you're planning on doing any string manipulation and not using some functions and expressions, you will be inventing something new. Sting manipulation invovles functions , expressions and modules.

    Here are a few links
    http://www.599cd.com/tips/access/bre...tr/default.asp
    http://www.databasedev.co.uk/access-...functions.html

  5. #5
    rudeamy is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    4
    Yup. This is what I thought. I'm going to need some big guns. Thanks for your help.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I need the data between "my name is" and "color" to appear in another field, called FirstLine.
    Let's say this text is in a field called - MyString

    so if "my name is" is in MyString, it starts at
    Instr(MyString,"my name is") let's just say it's position 15.
    and if "color" is in MyString, it starts at Instr(myString,"color")
    and let's say that returns 37.
    Now, the Mid() function
    In Access, the Mid function extracts a substring from a string (starting at any position).


    The syntax for the Mid function is:
    Mid ( text, start_position, number_of_characters )
    Text is the string that you wish to extract from.
    Start_position indicates the position in the string that you will begin extracting from. The first position in the string is 1.
    Number_of_characters indicates the number of characters that you wish to extract. If you omit this parameter, the Mid function will return all characters after the start_position.
    So the string you want is in MyString, after "my name is" and before "color".
    Using Mid, it becomes

    Mid(MyString,Instr(MyString,"my name is") + 11,Instr(MyString, "color") -1)
    The 11 represents the characters taken up by "my name is" (10) and then 1 char beyond that. The - 1 indicates the end of the string you want is 1 char before "color".

  7. #7
    rudeamy is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    4
    It worked. I cannot thank you enough!!

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

Similar Threads

  1. Widecard characters in Data-macro
    By abrian98 in forum Access
    Replies: 2
    Last Post: 09-01-2011, 07:43 PM
  2. Entry of Large Data Sets into multiple tables
    By bcouzens in forum Access
    Replies: 8
    Last Post: 05-26-2011, 02:22 PM
  3. selecting Sub-Form data from two inputs
    By techexpressinc in forum Queries
    Replies: 19
    Last Post: 12-03-2010, 11:03 AM
  4. Selecting Unique SETS of rows in Access Query
    By dalessandroh in forum Queries
    Replies: 0
    Last Post: 11-09-2010, 10:42 PM
  5. Parsing for data in between two characters
    By rawdata in forum Access
    Replies: 7
    Last Post: 11-02-2009, 04: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