473,385 Members | 1,610 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,385 software developers and data experts.

Run a query to update only the current record of table 1 to another table

Idea is to only update the new record called amount that reside in table 1 and update it to table 2.

I am trying to update amount of assets in a kit. So table named kit is the source and asset table is destination.

The problem I am having is query keeps updating every single record on kit table to asset table.

Expand|Select|Wrap|Line Numbers
  1. UPDATE Assets INNER JOIN Kits ON Assets.[Barcode ID] = Kits.[Barcode ID] SET Assets.[In Kit] = [Kits]![Amount]+[Assets]![In Kit];
  2.  
Apr 14 '15 #1
4 1649
Stewart Ross
2,545 Expert Mod 2GB
There is no WHERE clause in your query that could limit the update you are performing. You mention something about a new record containing an amount, but there is no reference to one and only one record in your update query - the join clause joins all records in your Assets table to all corresponding records in your Kits table on the common barcode ID field.

As you have not mentioned how you are identifying your new record I cannot suggest a suitable WHERE clause for you.

I think you may need to consider whether your design is properly normalised and implemented, as there is in general no need to store calculated fields in a table.

-Stewart
Apr 14 '15 #2
i forgot to post the WHERE clause
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Kits.[Date of creation])=Date()));
i did some research it says you can add a datetime/timestamp to the table that would store the insert/updated time of the record, and query based on that.

i actually added a column that says the date() However, when you create multiple records with the same barcode ID in the same day the amount that i want to update will be doubled.
Apr 14 '15 #3
Stewart Ross
2,545 Expert Mod 2GB
The date of creation is not unique and cannot be used to select just one record. Again, I think you need to look seriously at your design as it is almost certainly not in third normal form or higher from what you've told us so far.

-Stewart
Apr 14 '15 #4
zmbd
5,501 Expert Mod 4TB
ifclick... what SR is referring to is discussed here:
Database Normalization and Table Structures

Normalization of the database is an essential first step and not always easily done.

I usually suggest using the autonumber or guid as the primary key. It's unrelated to the data and no matter how the data is... "labeled" now or in the future, that PK field stays unchanged and easily used.
Apr 15 '15 #5

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

Similar topics

5
by: Mike | last post by:
Here is my situation; I have two tables in a MS-SQL DB. One table with dollar amounts and service codes. I have a second table that I want to move some information into from the first table. The...
1
by: Tony Johnson | last post by:
I want to update a particular field in a form for only a certain set of records. The certain set of records is named Financed. I need to update those Financed records with a financed number that...
3
by: JC Mugs | last post by:
2- Tables Customer & Invoice Customer has typical ID,Name, street, etc Invoice is special type has about 29 fields and needs to import the id, name, street, etc to this table. Save the total...
1
by: Joe Bloggs | last post by:
Hello, I have a form linking two tables but they have one field that is shared called "device" I want to allow data input into one of the fields and hide the other (so I need it automatically...
3
by: PAUL | last post by:
Hello, I have 2 datasets I am trying to update. The parent table seems to update fine but when I go update the chiled table I get an error message that says I need a related record in the parent...
2
by: Dixie | last post by:
I have a two column table which has a value for the current calendar year on a definite row(record) of the table, which could be described as ID=100. The value is in a field called txtValue. ...
0
by: cemal | last post by:
hi guys. I have two table ; categories and products categories table; catid (int) catname, and products table has catid(int), catname I want to update products.catid=catgory.catid where...
1
by: Jammin140900 | last post by:
Hi all, I'm new to all of this and this is probably straight forward. I have a form which is basically to be used like a checklist for a set of business processes in processing an application form...
5
by: ephi | last post by:
I have 2 tables in my database (Assets and AssetMovements). What I'm trying to achieve is that when the value of the 'Location' field is modified in a record in the 'Assets' table, once the user...
1
by: kcludick | last post by:
HI, I have a master table with records and a secondary table. I need to call up a record from the master table via a form, but the edited record must only save to the secondary table. The master...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.