473,761 Members | 10,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help with update query

23 New Member
Hello,

I am working on a very complex database and now I am trying to create an update query. The query is showing too few records. I am trying to update data in the table "inventory" with data from "workorder" table. The query is just copying the last workorder. I would like to update all new workorders to the inventory (can be until 100 records).

I would really appreciate your help! Thank you!

Imke
Oct 18 '06 #1
46 2896
jimatqsi
1,276 Recognized Expert Top Contributor
We're going to need some info about what your query looks like. Can you post the query/queries SQL code? Or describe any criteria you've applied?

Jim
Oct 19 '06 #2
arion
23 New Member
Hello,

the following is the SQL

UPDATE Inventory, WorkorderNewVal ve, [SQ Customers and Sales] INNER JOIN Workorders ON [SQ Customers and Sales].SalesID = Workorders.Sale sID SET Inventory.[Drawing#] = Left([Model#],5) & [Abbreviation], Inventory.Worko rderNumber = [Forms]![Sales Form].[SalesID] & [WOIndex], Inventory.Descr iption = [WorkorderNewVal ve].[part], Inventory.Mater ial = [Workorders].[Material], Inventory.Quant ity = [WorkorderNewVal ve].[Quantity], Inventory.Remar ks = [Workorders].[Remarks], Inventory.[Distinguishing Mark] = "changed"
WHERE (((Inventory.In ventoryID) Like [Forms]![First empty InventoryID]![InventoryID]));

Does that help? Thank you...

Imke
Oct 19 '06 #3
NeoPa
32,572 Recognized Expert Moderator MVP
It's still hard to see too much because we don't have the data, but I would guess, from the WHERE clause using the term 'Like' that you wanted to enter in the form a non-exact match.
If that is the case you want something like
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Inventory.InventoryID) Like "*" & [Forms]![First empty InventoryID]![InventoryID] & "*"));
as the last line.
If not, the last line should read
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Inventory.InventoryID) = [Forms]![First empty InventoryID]![InventoryID]));
although, to be honest, that would have little effect on the overall result.

I'm hoping the former is true because that might explain why fewer are found than you expected.
If not, something in the way of indicative data would be required.
Oct 19 '06 #4
arion
23 New Member
Unfortunately, it is not working. I need the second code that you suggested. I would like to update the first empty inventory ID. It is working perfectly with other update queries that I am using.

I am creating some workorders through clicking on a button in a form. There are one hundred workorders for each form. I am trying to update existing InventoryIDs with these workorders.

he InventoryIDs do exist because different databases will be imported in one main database, so each one needs to have its own id numbers.

The workordernumber s that should be copied are created through using the sales ID and the number of the workorder, e.g. the first one from saleID 1234 is then 123401. The update query is just showing the workordernumber 123499 instead of all 100, starting with 123401. Sorry, it is confusing. But does that help?
Oct 19 '06 #5
NeoPa
32,572 Recognized Expert Moderator MVP
Arion,

There's so much you're not telling here.
What you need to do is :-
1. Cut out everything from the query that isn't part of the problem. If you have any tables in there that make no difference - cut them out. If you have any field updates in there that make no difference - cut them out too.
2. Give enough data - example recordsets of the tables used - to show the problem, as well as the results which are wrong and explain what is expected.
3. Think of the terms you use. Do they mean anything generally, or are they terms that only mean something in your business or if you are already familiar with the work you're doing.

If you consider all these points then it should be a lot easier for someone to help you.
I'm going offline soon but I hope to catch up again tomorrow if I get any free time. If you can post something clearer then I'll certainly look at this thread first.

-NeoPa.
Oct 19 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Firstly, you have to create proper joins between all of your tables:

UPDATE (Inventory INNER JOIN
(WorkorderNewVa lve INNER JOIN
([SQ Customers and Sales] INNER JOIN Workorders
ON [SQ Customers and Sales].SalesID = Workorders.Sale sID)
ON WorkorderNewVal ve.[ID Field]=[SQ Customers and Sales].[ID Field])
ON Inventory.[ID Field]=WorkorderNewVa lve.[ID Field])
SET Inventory.[Drawing#] = Left([Model#],5) & [Abbreviation], Inventory.Worko rderNumber = [Forms]![Sales Form].[SalesID] & [WOIndex], Inventory.Descr iption = [WorkorderNewVal ve].[part], Inventory.Mater ial = [Workorders].[Material], Inventory.Quant ity = [WorkorderNewVal ve].[Quantity], Inventory.Remar ks = [Workorders].[Remarks], Inventory.[Distinguishing Mark] = "changed"
WHERE Inventory.Inven toryID=[Forms]![First empty InventoryID]![InventoryID];
Oct 20 '06 #7
arion
23 New Member
Now it is saying "Type mismatch in expressions"

UPDATE Inventory INNER JOIN (WorkorderNewVa lve INNER JOIN ([SQ Customers and Sales] INNER JOIN Workorders ON [SQ Customers and Sales].SalesID = Workorders.Sale sID) ON WorkorderNewVal ve.WOIndex = [SQ Customers and Sales].SalesID) ON Inventory.Inven toryID = WorkorderNewVal ve.WOIndex SET Inventory.[Drawing#] = Left([Model#],5) & [Abbreviation], Inventory.Worko rderNumber = [Forms]![Sales Form].[SalesID] & [WOIndex], Inventory.Descr iption = [WorkorderNewVal ve].[part], Inventory.Mater ial = [Workorders].[Material], Inventory.Quant ity = [WorkorderNewVal ve].[Quantity], Inventory.Remar ks = [Workorders].[Remarks], Inventory.[Distinguishing Mark] = "changed"
WHERE (Inventory.Inve ntoryID=[Forms]![First empty InventoryID]![InventoryID]);
Oct 20 '06 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
Are WorkorderNewVal ve.WOIndex and [SQ Customers and Sales].SalesID of the same Data type?

Are Inventory.Inven toryID and WorkorderNewVal ve.WOIndex of the same Data type?

If so, then check that all the following are of the same Data type also:

Inventory.[Drawing#] = Left([Model#],5) & [Abbreviation] Inventory.Worko rderNumber = [Forms]![Sales Form].[SalesID] & [WOIndex]
Inventory.Descr iption = [WorkorderNewVal ve].[part]
Inventory.Mater ial = [Workorders].[Material]
Inventory.Quant ity = [WorkorderNewVal ve].[Quantity] Inventory.Remar ks = [Workorders].[Remarks]
Inventory.[Distinguishing Mark] = 'changed'
Oct 20 '06 #9
arion
23 New Member
Yes, that was the mistake. WOIndex was a text field instead of numeric field.

But it is not updating the inventory table. Now, it is not showing any record in the inventory table.
Oct 20 '06 #10

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

Similar topics

2
1479
by: http://ray1.net/ | last post by:
Dear Readers. Using Javascript in ASP I need a way of returning through ADO (connection or recordset) the message returned via SQL when I run a query that UPDATES, DELETES or an SP that returns a message. So I basically when the below code gets executed I need a way of returning the message if it's there and if not nothing. a)
9
3137
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
2
1420
by: http://ray1.net/ | last post by:
Dear Readers. Using Javascript in ASP I need a way of returning through ADO (connection or recordset) the message returned via SQL when I run a query that UPDATES, DELETES or an SP that returns a message. So I basically when the below code gets executed I need a way of returning the message if it's there and if not nothing. a)
3
1878
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is not there, of course. How do I get that field back into the datatable for the database update? TIA, Larry Woods
2
5070
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 underlying subquery to this Update query involves a MAX function on a date field, which is then used in the DLookup statement. Any help appreciated. Thanks Richard
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.