Access query split function

Hello,

In an Access query in design mode, I need a simple way to split a string.  It will have more than three values.

Let's say my field Apple = "Hello,my,name,is,joel"

I want to do this:

Field A: Split ([Apple], "," 4)

The result should be "is".

Thanks for your help,
Joel
Joel AllenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
From:
https://access-programmers.co.uk/forums/showthread.php?t=217471

Tweak the function to:
Public Function ParseText(TextIn As String, SplitChar As String, X) As Variant
On Error Resume Next
Dim var As Variant
var = Split(TextIn, SplitChar, -1)
ParseText = var(X - 1)
End Function

Open in new window


Then this will run:
SELECT Apple, ParseText(Apple,",",4)
FROM Table1;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joel AllenAuthor Commented:
I'm sorry, I forgot how to get the following inserted into a function.  Can you help me?  I understand the second part though.

Public Function ParseText(TextIn As String, SplitChar As String, X) As Variant
On Error Resume Next
Dim var As Variant
var = Split(TextIn, SplitChar, -1)
ParseText = var(X - 1)
End Function
0
Joel AllenAuthor Commented:
Oh wait!  I figured it out.  Thank you!
0
Joel AllenAuthor Commented:
Thank you.  It worked!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.