Results 1 to 4 of 4
  1. #1
    funandlearning is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    2

    getting substring of a column value

    Hi All -

    My question is bit complicated to phrase it in the subject. Here are the details

    I have a table like below. I want to order the result set based on the 'q2' value of column2. "q2" is url variables of the URLs in columns2. Is this possible to do in MS Access?



    Column1 Column2
    1 www.yahoo.com?q=1&q2=abc
    2 www.yahoo.com?q=2&q2=def
    3 www.google.com?q=3&q2=ghij
    Thanks in advance

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Two options come to mind, both using the Mid() function. First is using the InStr() function to find the position of "q2" and grabbing data from there, the second is to use InStrRev() to find the position of the last "=" and grab data from there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    funandlearning is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    2
    Thanks for replying. There might more variables after q2 like

    www.yahoo.com?q1=1&q2=abc&q3=anything

    But q2 is always present.

    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Ah, a moving target. You might have to write a function that finds "q2", then steps through character by character until it finds the end, presumably the "&". You'd pass the entire string to the function and it would return the desired value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Substring Query
    By dandoescode in forum Queries
    Replies: 3
    Last Post: 06-15-2012, 12:54 PM
  2. Replies: 3
    Last Post: 03-14-2012, 06:48 AM
  3. IDCard Scanner substring
    By torpid in forum Programming
    Replies: 3
    Last Post: 05-30-2011, 07:16 AM
  4. Replies: 1
    Last Post: 04-15-2010, 02:07 AM
  5. Filtering using a Substring Help
    By r_walk76 in forum Forms
    Replies: 2
    Last Post: 01-11-2006, 07:13 AM

Tags for this Thread

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