Link to home
Start Free TrialLog in
Avatar of lux sat
lux sat

asked on

MS ACCESS

I have a table in MS ACCESS with a field Name STATE.

I need to update all the state field values to match with the list I have.

For example.

Connecticut  should read as CT
North Carolina should read as NC
Indiana should read as IN
Massachusetts should read as MA

I have all the distinct state values. If someone could help with the sample above that will be helpful
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Generally, I include both State_Name and State_CD in my states table.

I'm not sure what you have in mind though, and if you have a list of all the state names and codes, what do you need from us?
run a query with all of these sqls, it should fix your data:
update tablename set state='CT' where lcase(state)='connecticut';
update tablename set state='NC' where lcase(state)='north carolina';
update tablename set state='IN' where lcase(state)='indiana';
update tablename set state='MA' where lcase(state)='massachusetts';

Open in new window

of course replace tablename with your tablename
Why go to all that trouble Dany, when you could simply open the table and make the changes?  This is why I questioned what the OP really wants to do.
i assumed he has many (hundreds or thousands) of records.. and he wants to correct all his data!
Probably not a bad assumption, but I'd still just create a States table (tbl_States) with all of the correct values and then use that for the update.  The OP will likely still run into misspellings of the state names, but that should be minimal (hopefully).
True! i was just trying to answer the question as it is!
Avatar of lux sat
lux sat

ASKER

Dale:

My table(Candidate) consists of thousands of records with a STATE FIELD. I want to update all the state values.

I have selected distinct state values from the table (Candidate) and I have got that in a new table with state values matching with mine. check my attachment for a sample.  Basically trying to abbreviate (AZ,CA,CT,IN,NC,etc.....).

Thanks,
LakshmiSTATE-experts.xlt
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lux sat

ASKER

Dale:

Actually I need to update the Candidate table.

Thanks,
Lakshmi
That is what that query will do.  Create a table (tbl_States) from the Excel spreadsheet you sent.  Make the left column (I called it State_Name) the primary key of this table.  Then use the query I provided above to update all of the State field in the Candidates table.
Avatar of lux sat

ASKER

Thanks Dale
Glad I could help.