Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS ACCESS

Posted on 2014-11-19
12
Medium Priority
?
160 Views
Last Modified: 2014-11-20
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
0
Comment
Question by:lux sat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
12 Comments
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40453867
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?
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 40453876
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
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40453900
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.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 11

Expert Comment

by:Dany Balian
ID: 40453906
i assumed he has many (hundreds or thousands) of records.. and he wants to correct all his data!
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40453932
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).
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 40453944
True! i was just trying to answer the question as it is!
0
 

Author Comment

by:lux sat
ID: 40454046
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
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 40454064
If you modify the table that includes the distinct values from the [State] field (the Excel spreadsheet), and make the distinct value the primary key, you should be able to do an update, something like:

UPDATE Candidates INNER JOIN tbl_States
ON Candidates.State = tbl_States.State_Name
SET Candidates.State = tbl_States.[State_CD];
0
 

Author Comment

by:lux sat
ID: 40454085
Dale:

Actually I need to update the Candidate table.

Thanks,
Lakshmi
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40454715
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.
0
 

Author Comment

by:lux sat
ID: 40455062
Thanks Dale
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40455278
Glad I could help.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question