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

SQL Update Query that references another query and another table

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblCallLog SET tblCallLog.tblCallLog_shipmentID = (SELECT [queryNextShipmentID].[Next ShipID] FROM [queryNextShipmentID])
  2. WHERE ((tblCallLog.tblCallLog_clientID In (SELECT ListTop.tblCalLLog_clientID  FROM[ListTop])));
  3.  
Access is saying that this query is not updateable. Can anyone tell me why?
Apr 21 '11 #1

✓ answered by pod

I could be wrong, but I think your second level query is returning multple RECORDS which you are trying to insert into an integer field [tblCallLog_shipmentID]

If you have more than one client, you might be getting more than one NextShipmentID

and if you have more than one NextShipmentID record returned then the update query will throw an exception


troubleshooting:
I suggest run the second level and innermost query,
see what it returns you,
and assess from there

Expand|Select|Wrap|Line Numbers
  1. SELECT [queryNextShipmentID].[Next ShipID] FROM [queryNextShipmentID])
  2.     WHERE tblCallLog.tblCallLog_clientID In 
  3. (SELECT ListTop.tblCalLLog_clientID  FROM[ListTop])

4 1823
So, I'm guessing this code either looks right to most people or more information is needed to help me out.

I would suppose the query would be self-explanatory, but if it isn't, here is what I need from this query.

I need to set the tblCallLog_shipmentID field to the next shipmentID number (which I found in another query by selecting the maximum shipmentID plus one) where the clientID's of the callLog table are the same as the clientID's in the query ListTop. To get this result I am referencing two different queries, perhaps this is the problem? Any ideas of how I could get around that?

Thanks in advance.
Apr 22 '11 #2
pod
298 100+
I could be wrong, but I think your second level query is returning multple RECORDS which you are trying to insert into an integer field [tblCallLog_shipmentID]

If you have more than one client, you might be getting more than one NextShipmentID

and if you have more than one NextShipmentID record returned then the update query will throw an exception


troubleshooting:
I suggest run the second level and innermost query,
see what it returns you,
and assess from there

Expand|Select|Wrap|Line Numbers
  1. SELECT [queryNextShipmentID].[Next ShipID] FROM [queryNextShipmentID])
  2.     WHERE tblCallLog.tblCallLog_clientID In 
  3. (SELECT ListTop.tblCalLLog_clientID  FROM[ListTop])
Apr 25 '11 #3
Thank you, that was helpful advice, and my update query is now working.
Apr 25 '11 #4
NeoPa
32,556 Expert Mod 16PB
Check out Reasons for a Query to be Non-Updatable if you still need further understanding of this area.
Apr 26 '11 #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...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
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...
1
by: Dreamerw7 | last post by:
Hi, I know this is probably a dumb question, but here goes: I have 3 tables: REGION REG_ID REGION
1
by: TSA | last post by:
Hi all, Here's scenario: Table 1: Table1_pk A B C Table2_fk
4
by: tarafinlay | last post by:
Hi all, I am new to access and am finding it a bit unintuitive having worked with SQL server in the past... And I am in a bit of a hurry because my employer wants me to crank something out which...
4
by: Cyberwolf | last post by:
I have a form that users enter information into. What I want to do is to update certain fields from another table once they have entered a number in a field. The form is already based on a query...
1
by: jlrolin | last post by:
I'm trying to update a new field in a table from a COUNT(*) of Registration IDs grouped by Course IDs. COUNT: Course_ID 11 1234 12 2323 19 8932 ...
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: mharis | last post by:
I'm using MS SQL and I'm challenged with how update a table based on the count of records from another. I have a couple transactions for an id and I want to count total number and multiply by 4 or...
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: 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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.