Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query question

Status
Not open for further replies.

blaine011

IS-IT--Management
Jul 4, 2003
95
CA
I have a Table in this database, which can definitely be normalized quite a bit.

I need to create a query to replace city names with ref numbers.

I created a table from a query which selected all of the distinct names from the city field in the main Order Information table, called City. After that I added a field in the city table called cref. Which I then linked with relationships.

Now what I want to do in the Order Information table, is replace all of the city names with just the corresponding cref number from the City table.

How can I do this?
 
UPDATE [Order Information]
SET [Order Information].City = City.CityRef
WHERE [Order Information].City = City.City;

 
Make sure the City field in the City table (consider a naming convention) is the primary key. You can then place both tables in a query and join the City fields. Change the query to an update query and enter [cref] in the Update To of the appropriate field in the OrderInformation table.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top