Extract Data

G

Guest

I need to extract a portion of a text field and I don't have a clue how to do
it. I know it can be done because I recall seeing someone else do it but for
the life of me I cannot remember.

Basically I have a text field that contains some information in the middle
of it that is surounded by quotes and I need to extract only that part. Can
someone tell me how I can extract it?

Thank you in advance,
Tony
 
J

JohnFol

Depends where you are doing it, and if you can guarantee the quotes will be
there. For eexample ina query you can use:
Instr will return the position of the first quote
Using this value do another Instr to get the 2nd quote
Use Mid to extract out the section you want.


Or, do this if in VBA

Function GetMiddleBit(strInput as string) as string

Dim strResults() As String
strResults = Split( " " & strInput & " ", Chr(34))
GetMiddleBit = strResults(1)
End Function

and to test


Dim strTest As String
strTest = GetMiddleBit("Hello " & Chr(34) & "world" & Chr(34) & " How are
you?")
 
G

Guest

Thank you very much for your help. I recall seeing the Instr function before
so I'm confident that will work.

Thanks again,
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top