473,399 Members | 3,302 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,399 software developers and data experts.

Update query with Dlookup function results in conversion error

Hi Everyone,

I've created a database (MS Access 2003) to help monitor staffing at my work.

I now need to transcribe data from one table (tblPositions) into another (tblTeams) based on a common column (Position ID). Essentially I wish to copy the [Position title] and [Position description] of different positions from tblPositions, into tblTeams according to their already recorded [Position ID] (this is to make the data more readable).

Having looked through this and other forums I've been attempting to automate this process using an UPDATE statement. It is as follows:

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTeams SET tblTeams.[Position description] = (DLookUp("[Description]","tblPositions","(tblPositions.[Position code] = " & tblTeams.[Position code] & ""))
  2. WHERE (((tblTeams.[Position code])=30471524));
Please note the WHERE statement is only here to as a testing clause (I don't want to overwrite any data accidentally).

Every time I've trialled this query however I receive an error box citing a Conversion error as my problem. I've checked and re-checked again and again and as far as I can tell all the fields (description, title, position ID) all have identical formatting.

Is there any other way a Conversion error might be generated?
Is there a better way of doing this?
As a worst case scenario I can manually re-type the data (only about 200-250 records) but I think solving this now will lead to many time saving gains in the future.

Many thanks!

James
May 15 '11 #1

✓ answered by NeoPa

Hi James. Welcome to Bytes!

Your question indicates a level of inexperience with databases generally (excuse me for mentioning), and a lack of awareness of the fundamental and critically important concept of Normalisation (Database Normalisation and Table structures) particularly. I won't go into all the details of that as the link covers it well already. Suffice to say that updating the related table as you are trying to do is a very bad idea.

If you were to continue with this approach against the express warnings of an experienced database developer, then you would probably want to do it with a JOIN in your SQL instead of using a Domain Aggregate function (DLookup()) as this is a clumsy alternative and not necessary.

Finally, if you're not happy with any of the advice, or even for the sake of simple curiosity, the end of your first line should look like & ")") as the first parenthesis of the two is part of the WHERE string supplied as the last parameter to DLookup().

4 4198
NeoPa
32,556 Expert Mod 16PB
Hi James. Welcome to Bytes!

Your question indicates a level of inexperience with databases generally (excuse me for mentioning), and a lack of awareness of the fundamental and critically important concept of Normalisation (Database Normalisation and Table structures) particularly. I won't go into all the details of that as the link covers it well already. Suffice to say that updating the related table as you are trying to do is a very bad idea.

If you were to continue with this approach against the express warnings of an experienced database developer, then you would probably want to do it with a JOIN in your SQL instead of using a Domain Aggregate function (DLookup()) as this is a clumsy alternative and not necessary.

Finally, if you're not happy with any of the advice, or even for the sake of simple curiosity, the end of your first line should look like & ")") as the first parenthesis of the two is part of the WHERE string supplied as the last parameter to DLookup().
May 15 '11 #2
Hi NeoPa,

Thank-you very much for your rapid and comprehensive answer.

I intend on re-designing the database in light of the article on normalisation you referred to. I fell into a trap of believing there was such a thing as too many tables, when further normalisation would have probably saved me a lot of trouble initially.

I have tested the syntax correction you posted which worked 'perfectly' in my flawed system. Whilst initially I will have to utilise this fix to keep my managers happy, the re-designing process should be enlightening.

Please note the following section deviates from my original post. Please simply let me know if I should start a whole new thread and I will do so.
One underlying issue to the current state of affairs is modifying data that I have generated using JOIN queries. The key example would be generating a query of my database that combined information from the Staff, Positions and Allocations tables. Using such a query I would be able to see the Staff name, Allocated position number, and Position description (using the common fields in the Allocations table -- StaffID allocated to a PositionID).
However, in my initial testing of such joins, I was unable to edit the data generated by such a query -- the key element in creating the query in the first place.

Is there a way to allow updates to occur across the tables? Does it lie in re-designing the database to only have 1-to-1 relationships?

Many thanks for any more assistance. Again, I will happily re-post to a new topic if that is general policy.

James
May 16 '11 #3
NeoPa
32,556 Expert Mod 16PB
James,

Clearly your inexperience is limited to database design (and I have a funny feeling that won't last long either). An impressive response, and, Yes, the new question will need to be posted in its own separate thread, but we (I was chatting with the Normalisation article author and site administrator Mary about your response just now) are very much looking forward to seeing it. We both feel that it could prove a seed for a good discussion on related topics (as well as providing you with a number of potential solutions to your issues).

I'm really quite unused to new members understanding that our rules insist on separate threads for separate questions. I usually have to split the new question off from the first one and explain the situation patiently (I'm good at the first step but make no claim to the requisite patience for the second).

The recommended procedure at this point would be to formulate your question in a new thread and then to add a new post in this one with a link to that new thread. That is perfectly acceptable, and gives an opportunity for any members already subscribed to this thread to become aware of the new one without having to catch it from among all the new threads we get every day in the forum.

I'll save my contributions for the new thread as that will keep everything together for anyone searching later ;-)

-NeoPa.
May 17 '11 #4
Hi NeoPa,

I'm glad I could be somewhat of a surprise for you. It all seemed fairly common sense to me keeping each topic about that topic, but I work in healthcare and I appreciate how uncommon sense can be at times.

Thank-you for your reply, I have started a new thread and hope to learn much from you and the Community.

-James
May 17 '11 #5

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

Similar topics

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...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
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...
1
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
2
by: Reedsp | last post by:
OS: MS XP Access version: 2003 SP2 I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
11
by: gnortenjones | last post by:
I have a linked table (to an oracle db), and I am trying to run a simple update query against it to change some data, but I am getting the following error: "...didn't update 0 fields due to a type...
4
by: JamieF | last post by:
Sorry if I've missed something obvious, but I'm trying to do a really basic update query in Access 2007, and I can't get it to work. UPDATE DISC INNER JOIN DISC2 ON DISC.DiscID = DISC2.DiscID SET...
1
by: goslincm | last post by:
Good morning, I'll try to describe this in 3 parts: Part 1: I have 2 linked tables that are my source for a query that I am creating for the purpose of being able to create a new field name (by...
1
by: giovannino | last post by:
Dear all, I did a query which update a sequence number (column NR_SEQUENZA) in a table using a nice code (from Trevor !). 1) Given that I'm not a programmer I can't understand why...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.