Textpart

G

Guest

Hi I have an access database that has a text field with example data as
follows:

john smith - British airways
johnathen Smith - British Airways
Judy - National Geographic

Is there a way, using a Select query to return just the data after the "-"

Please accept my thanks in anticipation.

Kind Rgds
Colin
 
K

Ken Snell [MVP]

SELECT Mid([FieldName], InStr([FieldName], " - ") + 3) AS Affiliation
FROM TableName;
 
D

Douglas J. Steele

Assuming there's only a single space between the hyphen and the text, I
think that needs to be

SELECT Mid([FieldName], InStr([FieldName], " - ") + 2) AS Affiliation FROM
TableName;

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
SELECT Mid([FieldName], InStr([FieldName], " - ") + 3) AS Affiliation
FROM TableName;

--

Ken Snell
<MS ACCESS MVP>



colin said:
Hi I have an access database that has a text field with example data as
follows:

john smith - British airways
johnathen Smith - British Airways
Judy - National Geographic

Is there a way, using a Select query to return just the data after the
"-"

Please accept my thanks in anticipation.

Kind Rgds
Colin
 
K

Ken Snell [MVP]

Would depend upon whether you want to include the space after the hyphen in
the extracted string or not. If the text string is
ken - snell

Using +3, the expression would return
snell

Using +2, the expression would return (note the leading space character)
snell

--

Ken Snell
<MS ACCESS MVP>


Douglas J. Steele said:
Assuming there's only a single space between the hyphen and the text, I
think that needs to be

SELECT Mid([FieldName], InStr([FieldName], " - ") + 2) AS Affiliation FROM
TableName;

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
SELECT Mid([FieldName], InStr([FieldName], " - ") + 3) AS Affiliation
FROM TableName;

--

Ken Snell
<MS ACCESS MVP>



colin said:
Hi I have an access database that has a text field with example data as
follows:

john smith - British airways
johnathen Smith - British Airways
Judy - National Geographic

Is there a way, using a Select query to return just the data after the
"-"

Please accept my thanks in anticipation.

Kind Rgds
Colin
 
D

Douglas J. Steele

Actually, the problem was that I didn't notice that you were looking for " -
", not "-".

Sorry for the intrusion...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
Would depend upon whether you want to include the space after the hyphen
in the extracted string or not. If the text string is
ken - snell

Using +3, the expression would return
snell

Using +2, the expression would return (note the leading space character)
snell

--

Ken Snell
<MS ACCESS MVP>


Douglas J. Steele said:
Assuming there's only a single space between the hyphen and the text, I
think that needs to be

SELECT Mid([FieldName], InStr([FieldName], " - ") + 2) AS Affiliation
FROM TableName;

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
SELECT Mid([FieldName], InStr([FieldName], " - ") + 3) AS Affiliation
FROM TableName;

--

Ken Snell
<MS ACCESS MVP>



Hi I have an access database that has a text field with example data as
follows:

john smith - British airways
johnathen Smith - British Airways
Judy - National Geographic

Is there a way, using a Select query to return just the data after the
"-"

Please accept my thanks in anticipation.

Kind Rgds
Colin
 
K

Ken Snell [MVP]

No problem! :)

--

Ken Snell
<MS ACCESS MVP>

Douglas J. Steele said:
Actually, the problem was that I didn't notice that you were looking for
" - ", not "-".

Sorry for the intrusion...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
Would depend upon whether you want to include the space after the hyphen
in the extracted string or not. If the text string is
ken - snell

Using +3, the expression would return
snell

Using +2, the expression would return (note the leading space character)
snell

--

Ken Snell
<MS ACCESS MVP>


Douglas J. Steele said:
Assuming there's only a single space between the hyphen and the text, I
think that needs to be

SELECT Mid([FieldName], InStr([FieldName], " - ") + 2) AS Affiliation
FROM TableName;

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



SELECT Mid([FieldName], InStr([FieldName], " - ") + 3) AS Affiliation
FROM TableName;

--

Ken Snell
<MS ACCESS MVP>



Hi I have an access database that has a text field with example data
as
follows:

john smith - British airways
johnathen Smith - British Airways
Judy - National Geographic

Is there a way, using a Select query to return just the data after the
"-"

Please accept my thanks in anticipation.

Kind Rgds
Colin
 

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