MS Access regex

Posted on 2012-09-07
Last Modified: 2012-09-07

I'm wondering how I can use VBA with I guess regex or some other function to get everything after "Music Lessons:" in these strings:
Music Lessons:Smith, John
Music Lessons:Alley, Joan
Music Lessons:Lee, Brady

Thank you,
Question by:Victor Kimura
    LVL 65

    Accepted Solution

    Right("Music Lessons:Lee, Brady", Len("Music Lessons:Lee, Brady") - InStr(1, "Music Lessons:Lee, Brady", ":"))

    Edit the above to replace "Music Lessons:Lee, Brady" with whatever column / variable you are using for these names.
    LVL 92

    Assisted Solution

    by:Patrick Matthews
    Another way:

    Mid(SomeColumn, InStr(1, SomeColumn, "Music Lessons:") + 1)

    If you can get away with just "whatever comes after the first colon":

    Mid(SomeColumn, InStr(1, SomeColumn, ":") + 1)

    To return a blank if "Music Lessons:" does not appear:

    Mid(SomeColumn, InStr(1, SomeColumn & "Music Lessons:", "Music Lessons:") + 1)

    To return a blank if no colon appears:

    Mid(SomeColumn, InStr(1, SomeColumn & ":", ":") + 1)
    LVL 74

    Assisted Solution

    by:käµfm³d 👽
    ...or even:

    Dim onTheRight
    onTheRight = Replace(theColumn, "Music Lessons:", "")

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now