Re: Copy only part of text string

Tech-Archive recommends: Fix windows errors by optimizing your registry



InStr() could be used to spot the word Error:

? InStr("Hello, World, is that an error we just saw?"", "Error" )
26

So, you can then retrieve from that position (+5, if you don't want the word
error itself):


Mid( myString & "Error", 5+ InStr(myString & "Error", "Error") )


Note that I appended the searched string to the initial string, so it is
always 'found'. Indeed, if the string is not found, InStr returns 0 and Mid
would produce an error, in that case.




Hoping it may help,
Vanderghast, Access MVP


"hobbit2612 via AccessMonster.com" <u27332@uwe> wrote in message
news:7195904679508@xxxxxx
Hi,

Wonder if someone maybe able to help me please.

I have a database at work that contains details of test files. One of the
fields for each test shows that actual error that caused the file to fail.
The problem is, is that there is an awful lot of text from this field that
I
don't need to extract.

The text I need to extract starts with the word Error and then the rest of
the text that comes after it in the text string. The word Error can appear
anywhere within the text string, but having worked through all of the
failures I beleive that 'Error' can be used as the guide to start
extracting
from.

I'm fairly new to Access, and I did try using the 'Mid' and 'Last'
functionaity, but this didn't seem to work.

Could someone perhaps point me in the direction please of how I could put
a
function/coding into a query that will extract the information and where
if
the word 'Error' doesn't appear within the text string it just leaves the
field blank in the query.

Many thanks an regards

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200705/1



.



Relevant Pages

  • Copy only part of text string
    ... I have a database at work that contains details of test files. ... don't need to extract. ... the text that comes after it in the text string. ... The word Error can appear ...
    (microsoft.public.access.queries)
  • Re: String Too Long
    ... "JF Bouthillier" wrote in message ... This is a Word error. ... > When the String is longer than 255, ... (please reply to the newsgroup) ...
    (microsoft.public.access.modulesdaovba)
  • Re: Extract Data
    ... Depends where you are doing it, and if you can guarantee the quotes will be ... Using this value do another Instr to get the 2nd quote ... Use Mid to extract out the section you want. ... Function GetMiddleBit(strInput as string) as string ...
    (microsoft.public.access.queries)