UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Parse A Middle Value From Text, Any Version    
 
   
sarcher
post Mar 5 2018, 10:18 AM
Post#1



Posts: 19
Joined: 30-November 12



Looking to Parse a middle section of a text field for a value between the '\'

So

E:\MyFolder\TEMP\TRF 000-003AA\Data\TRF 000-003AA.pdf

would return "TRF 00-003AA"

E:\MyFolder\TEMPDATA\SBA 0%AA\Data\SBA 000-00%AA.pdf

would return "SBA 0%AA"

so I need everything between the third "\" and fourth "\"

TIA

Steve




Go to the top of the page
 
LPurvis
post Mar 5 2018, 10:37 AM
Post#2


UtterAccess Editor
Posts: 16,271
Joined: 27-June 06
From: England (North East / South Yorks)


Hi there.

It's good that you clarified the definition of the "middle" there ;-).
If you're sure it's always the 3rd and 4th slashes that define your section, it can be as simple as:

Split([YourField],"\")(3)

But that can be better wrapped up in a function of course.

Cheers

--------------------
Go to the top of the page
 
LPurvis
post Mar 5 2018, 10:41 AM
Post#3


UtterAccess Editor
Posts: 16,271
Joined: 27-June 06
From: England (North East / South Yorks)


Ah, I see this is in Queries forum.
You'll likely want a solution that can be used as an expression then.

Again, you could make this into a function, rather than a relatively more messy Mid and Instr expression.

Save as a function in a standard module
CODE
Function fGetSection(varCal, strDelim As String, intPost As Integer)
    
    fGetSection = Split(varCal, strDelim)(intPost)
    
End Function

Then you can call that from an expression:
fGetSection([YourField],"\",3)
But it's also re-usable for other scenarios you might encounter.

Cheers

--------------------
Go to the top of the page
 
sarcher
post Mar 5 2018, 11:59 AM
Post#4



Posts: 19
Joined: 30-November 12



Perfect - thank you
Steve
Go to the top of the page
 
LPurvis
post Mar 5 2018, 12:07 PM
Post#5


UtterAccess Editor
Posts: 16,271
Joined: 27-June 06
From: England (North East / South Yorks)


No worries, glad you found it OK.
Increasing your bank of re-usable functions is always a good thing :-).

Cheers

--------------------
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd June 2018 - 09:10 AM