Results 1 to 5 of 5
  1. #1
    cleme1q is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    3

    Characters before searched string


    Is there a function, similar to mid, except that it will return all characters prior to the searched string instead of after?

    Thanks

  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,640
    How about Left(), using InStr() to find the position of the string?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cleme1q is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    3
    Quote Originally Posted by pbaldy View Post
    How about Left(), using InStr() to find the position of the string?
    Unfortunately that won't work because there are multiple instances of the character and I am using InstrRev to find the position of the last instance so that I can go backwards from that as content for the next column in the query.

    Thanks for the idea.

  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,640
    Can you post an example of the string and the desired result?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    cleme1q is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    3
    I am using access to link to an Exchange inbox. One of the columns is the content of an email. The amount of text in the content varies with each email. Here is an example of the string but there could be more or less rows of data in the content, always delimted by a |:

    ops25 [3084:i2cus02:2] | 2044.0 | SYSLOCAL | launch13-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 10/125 | Table Scan: ECUK_CUST.SUP_00000098174: 5081 out of 68584 Blocks done
    ops25 [3084:i2cus02:2] | 2730.0 | SYSLOCAL | launch10-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 10/125 | Table Scan: ECUK_CUST.SUP_00000098174: 5081 out of 68584 Blocks done
    ops25 [3084:i2cus02:2] | 2847.0 | SYSLOCAL | launch14-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 10/125 | Table Scan: ECUK_CUST.SUP_00000098174: 5081 out of 68584 Blocks done
    ops25 [3084:i2cus02:2] | 2589.0 | SYSLOCAL | launch12-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 10/125 | Table Scan: ECUK_CUST.SUP_00000098174: 5081 out of 68584 Blocks done
    ops25 [3084:i2cus02:2] | 2390.0 | SYSLOCAL | launch11-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 11/138 | Table Scan: ECUK_CUST.SUP_00000098174: 5081 out of 68584 Blocks done
    ops25 [3084:i2cus02:2] | 2739.0 | NEWLOOK_CUST | ws02-ri2.ri2.dc1.responsys.com | Table Scan | 37% | Blocks | 175/304 | Table Scan: NEWLOOK_CUST.SUP_00000104743: 52172 out of 142640 Blocks done
    ops25 [3084:i2cus02:2] | 2478.0 | INTBUIS_CUST | launch11-ri2.ri2.dc1.responsys.com | Table Scan | 65% | Blocks | 1020/551 | Table Scan: INTBUIS_CUST.PRO_00000097988: 524944 out of 808431 Blocks done
    ops28 [3519:i2cus04:4] | 3030.0 | MICHCONS_CUST | launch02-ri2.ri2.dc1.responsys.com | Table Scan | 8% | Blocks | 10/124 | Table Scan: MICHCONS_CUST.SUP_00000001080: 10195 out of 136136 Blocks done
    ops7 [1022:cust01:1] | 2426.0 | SFI_CUST | cleit.prod.responsys.com | Table Scan | 83% | Blocks | 2876/617 | Table Scan: SFI_CUST.PRO_00010881853: 1557897 out of 1891855 Blocks done
    ops7 [1022:cust01:1] | 2971.0 | PRODAPP_PTRAN | RESPONSYS\CORPDC5700PTRAN | Table Scan | 80% | Blocks | 28098/7350 | Table Scan: SPEEDD_CUST.PRO_00001483931: 2117582 out of 2671454 Blocks done



    One column in my query finds the last occurrence of the | and prints out the 30 characters following. The next column in my query should exclude the | that was found, find the next one and print the 30 following characters. I am doing this up to 10 columns.


    For example:


    SELECT DatePart('ww',[received]) AS WeekoftheYear, OrionInbox2.Received, Mid([contents],InStrRev([OrionInbox2]![Contents],"|"),30) AS Account,
    Mid(Mid([contents],InStrRev([OrionInbox2]![Contents],"|")),InStrRev([Contents],"|",InStrRev([Contents],"|")-180),30) AS Account2,


    For the Account2 portion of the query I am trying to exclude the data from Account that was found as the content of Mid but because Mid only displays forward characters, it does not work correctly.

    Ideally, Account would return '| Table Scan: SPEEDD_CUST.PRO' and Account2 would return ' | Table Scan: SFI_CUST.PRO_0'

    I know this seems convoluted.. thanks for the help.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-02-2011, 11:20 AM
  2. Replies: 4
    Last Post: 07-19-2011, 09:11 AM
  3. Replies: 5
    Last Post: 03-10-2011, 02:19 PM
  4. how select middle characters on string ???
    By ayman.maher in forum Queries
    Replies: 1
    Last Post: 04-27-2010, 09:29 AM
  5. replace characters in a string
    By blazixinfo@yahoo.com in forum Access
    Replies: 6
    Last Post: 08-06-2009, 03:36 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