Working with a String

  • Thread starter Anthony Viscomi
  • Start date
A

Anthony Viscomi

I have a table(s) that is imported nightly from a Main Frame; within that
table there is a field Addr3 that contains data that looks like the
following:

EL DORADO, AR
PINE BLUFF, AR
MURFREESBORO, TN

Obviously this data represents City & State; my problem is that I am only
concerned with the City portion of this data. Please note there is always a
comma after the City. I would like to via a query or code only view the City
at that point I wxport to query to a csv file. Can somone please help?

Thanks,
Anthony
 
B

Brendan Reynolds

SELECT Left$([CityState],InStr(1,[CityState],",")-1) AS City,
Trim$(Mid$([CityState],InStr(1,[CityState],",")+1)) AS State
FROM tblTest;

See Left Function, InStr Function, Trim Function and Mid Function in the
help files for more info.
 
C

Cheryl Fischer

You can create a string containing only the City by using the Left()
function:

Left([MyField], InStr([MyField], ",") -1)

You can use this expression in a query by simply inserting it into the
Field: row of a query column.
 
A

Anthony Viscomi

Works great! Thanks to all!
Cheryl Fischer said:
You can create a string containing only the City by using the Left()
function:

Left([MyField], InStr([MyField], ",") -1)

You can use this expression in a query by simply inserting it into the
Field: row of a query column.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Anthony Viscomi said:
I have a table(s) that is imported nightly from a Main Frame; within that
table there is a field Addr3 that contains data that looks like the
following:

EL DORADO, AR
PINE BLUFF, AR
MURFREESBORO, TN

Obviously this data represents City & State; my problem is that I am only
concerned with the City portion of this data. Please note there is
always
a
comma after the City. I would like to via a query or code only view the City
at that point I wxport to query to a csv file. Can somone please help?

Thanks,
Anthony
 

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