Results 1 to 5 of 5
  1. #1
    pderwael is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    3

    EXtracting substring from a string

    Hi folks,




    I was using Excel to manage quite a large music DB when I hit the hard limit of Excel of about 1M lines, so I have no other option than switch to Access
    As I'm not quite an Access expert, this is when I'm starting to tear my hair off


    One of my DB fields contains paths and I need to extract the directory part of it
    There are 3 types of strings:


    M:\~Check\Artist - Year - Album\Track - Title
    M:\~Queue\Artist - Year - Album\Track - Title
    M:\R\Artist - Year - Album\Track - Title


    With the builder, I have set the following formula:


    IIf(Mid([Tracklist_Import]![Path],4,1)="~",Mid([Tracklist_Import]![Path],5,5),Mid([Tracklist_Import]![Path],4,1))


    For the 3 above lines, in my understanding, this should return
    Check
    Queue
    R


    But this actually returns the following:
    ~Check\Artist - Year - Album\Track - Title
    ~Queue\Artist - Year - Album\Track - Title
    R\Artist - Year - Album\Track - Title


    Any advice would be appreciated!


    Thanks a lot!

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    The formula along with the data you provided works as expected on my end...

    Click image for larger version. 

Name:	Untitled.png 
Views:	27 
Size:	16.6 KB 
ID:	46933

    By the way, PATH is a reserved word. You should avoid giving fields or anything else a name that's a reserved word: http://allenbrowne.com/AppIssueBadWord.html

  3. #3
    pderwael is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    3
    Weird (to say the least...)


    I have changed the "Path" to "Paath" just in case this would make any difference (didn't make any)


    As I have just upgraded my home PC to Win 11 (with Access 2016), I thought this could be related to the Windows version
    So, I tried on my work PC which is running Win 10 & Office 365: no difference either


    I guess I will have to work it around by using lots of string functions, even if this is not the cleanest way forward...

  4. #4
    pderwael is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    3
    Issue finally solved

    SOlution found in this thread:
    https://www.accessforums.net/showthread.php?t=78802

    All I had to do was to change the list separator in my regional settings from comma to semicolon

    I now "just" have to pay attention to other exports which might be impacted by this change as well!

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by pderwael View Post
    Issue finally solved

    SOlution found in this thread:
    https://www.accessforums.net/showthread.php?t=78802

    All I had to do was to change the list separator in my regional settings from comma to semicolon

    I now "just" have to pay attention to other exports which might be impacted by this change as well!
    Nicely found.
    Not seen that problem before
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. extracting from middle of string
    By sem1604 in forum Queries
    Replies: 3
    Last Post: 05-08-2018, 04:52 AM
  2. Substring in VBA Access
    By newbie30 in forum Programming
    Replies: 5
    Last Post: 11-14-2017, 08:10 AM
  3. Extracting text from a string
    By Whughes98 in forum Queries
    Replies: 5
    Last Post: 04-17-2017, 11:18 AM
  4. Replies: 16
    Last Post: 11-03-2014, 02:38 PM
  5. Replies: 2
    Last Post: 11-02-2012, 01:20 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