473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Update query with table values in a range

I'm using MS Access 2007 and I have a table that has a field wtih 188 unique values (3 digit). I want to convert them to one of 22 unique values (2 digit).

I have an excel spread sheet of what each unique 3 digit value should map too and there's really no rhyme or reason to it so I can't specify ranges.

Please see the attached example.

Not sure if I Should use the dlookup function or create an update query with with 188 diferent criterion. I'd like to utilize a query so I can add it to my current access db project though I'm not opposed to using VBA if its better/easier.
Attached Files
File Type: xlsx Example.xlsx (10.2 KB, 442 views)
Apr 2 '14 #1
4 1891
Rabbit
12,516 Expert Mod 8TB
Just import that excel sheet into Access and join to it on the 3 digit value to get the 2 digit value.
Apr 3 '14 #2
Rabbit,

Maybe I'm making this harder than it is but, don't I have to map each individual 3 digit value to the specific 2 digit value? I don't understand how a simple join would convert values correctly.

The long drawn out way would be to make 22 update queries that update specific 3 digit values to their respective 2 digit values.
Apr 3 '14 #3
Rabbit
12,516 Expert Mod 8TB
I assume you have something like this:

Table1
Code3 - CHAR(3)

Table2 (imported from excel)
Code3 - CHAR(3)
Code2 - CHAR(2)

Then this join returns the Code2 from the first table's Code3.
Expand|Select|Wrap|Line Numbers
  1. SELECT Code2
  2. FROM
  3.    Table1 INNER JOIN
  4.    Table2 ON Table1.Code3 = Table2.Code3
Apr 3 '14 #4
NeoPa
32,556 Expert Mod 16PB
The join gives you access to the related values. Consider the scenario painted by Rabbit but assume your original data in [Table1] also has a field called [Code2] added which starts with nothing in it. A simple update query could be set up to apply the desired values (held in [Table2]) to the new field in your original data :
Expand|Select|Wrap|Line Numbers
  1. UPDATE [Table1]
  2.        INNER JOIN
  3.        [Table2]
  4.     ON Table1.Code3=Table2.Code3
  5. SET    Table1.Code2=Table2.Code2
SQL like this would go through every record of [Table1] and take the matching record from [Table2]. It then, for each record, adds the [Code2] value from [Table2] into the [Code2] field of [Table1]. Does that make sense?
Apr 3 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: David Shorthouse | last post by:
Hello folks, I have a problem with an update query on an asp not updating the table in an Access db. The code runs, I have no errors, but when I examine the table, nothing was updated. The query...
3
by: rrh | last post by:
I am trying to update a field in one table with data from another table. The problem I'm running into is I need to base the update on a range of data in the 2nd table. Table 1 has: date field...
3
by: deko | last post by:
I know I can use Inner Joins in an Update query like this: UPDATE DISTINCTROW tblA INNER JOIN qryA ON tblA.SomeID = qryA.SomeID SET Flag = 0 WHERE (Flag = -1); But I am specifying the new...
15
by: Darren | last post by:
Help, i want to run an update query from a form.. and was wonderin.. Can the update query run if i want to update a value manually inputted from a form (e.g. !!) to a table...
1
by: G Gerard | last post by:
Hello I am trying to update a table (TableB) using records from a second table (TableA)
3
by: hharriel | last post by:
Hi All, I have created an update query related to high school course information (name of course; credit hour; course description, etc.) I am updating a master course information table. I am...
3
by: ringer | last post by:
I am trying to add a functionality into a db I use for my checkbook that will help me plan for and save money for future large expenses. Into a table called tblFutureTransactions I want to enter...
2
by: Joey | last post by:
I am querying a DataSet with LINQ. I am running into a problem when trying to construct my query because in the "from" clause I do not know the table name (range variable) until runtime. Possible...
1
by: islandgal | last post by:
-- -- Table structure for table borrower -- DROP TABLE IF EXISTS borrower; CREATE TABLE borrower ( brw_num int(11) NOT NULL default '0', brw_lname varchar(15) default NULL, brw_fname...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.