Help in parsing a field based on multiple delimiters

brosenfelt

New Member
Joined
Aug 13, 2015
Messages
1
Hi guys -- brand new to Access -- but making good progress. Trying to NOT use VB to accomplish this (for a variety of reasons).

I have a field in our database with five distinct strings, separated by a delimited (a slash or "/").

I've been able to successfully write the formula to parse the first field:

ARL: Left$([pipeline]![Short Description],InStr(1,[pipeline]![Short Description],"/")-1)

The second field:

BRANCHMGR: Mid(Left([pipeline]![Short Description],InStr(InStr(1,[pipeline]![Short Description],"/")+1,[pipeline]![Short Description],"/")-1),InStr(1,[pipeline]![Short Description],"/")+1)

and the last field:

DATE: Mid$([pipeline]![Short Description],InStrRev([pipeline]![Short Description],"/")+1)

Having trouble figuring out how to get the third and fourth strings parsed. I know its going to include some nested InStr or InStrRev commands -- just having trouble figuring out the structure. Could potential need a LEN command as well.

Thanks for your assistance.

Typical field might look like this:

"Name1/Name2/Description/Update/Date"

Regards.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
"Trying to NOT use VB to accomplish this (for a variety of reasons)."

no idea what the reasons are, but this is made for VB

create a module
put this code in it


Code:
'*****************************************************
Function get_field(this_index As Variant, f As Variant) As Variant
    
    If IsNull(f) Then
        get_field = Null
    Else
        Dim arr As Variant
        arr = Split(f, "/")
        If this_index > UBound(arr) Then
            get_field = Null
        Else
            get_field = arr(this_index)
        End If
    End If
    
End Function
'*****************************************************

then write your query

ARL: get_field( 0, [pipeline]![Short Description] )

BRANCHMGR: get_field( 1, [pipeline]![Short Description] )

DATE: get_field( 2, [pipeline]![Short Description] )

field4: get_field( 3, [pipeline]![Short Description] )

field5: get_field( 4, [pipeline]![Short Description] )
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,130
Messages
6,129,056
Members
449,484
Latest member
khairianr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top