Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with updating data

Status
Not open for further replies.

Peps

Programmer
Feb 11, 2001
140
ES
Hi there,

I have two tables [Deposito_Temporal_Entrada] and [Importación_DT_Salida] both tables are receiving imports from Excel. I have to be able to update the [Importación_DT_Salida] table with data from the [Deposito_Temporal_Entrada] automatically.

The below SQL returns those values with iqual instances in the [AUTORIZACIÓN] field.

SELECT Importación_DT_Salida.AUTORIZACIÓN, Importación_DT_Salida.Id, Deposito_Temporal_Entrada.Id
FROM Importación_DT_Salida RIGHT JOIN Deposito_Temporal_Entrada ON Importación_DT_Salida.AUTORIZACIÓN = Deposito_Temporal_Entrada.Autorización
WHERE ((Not (Importación_DT_Salida.AUTORIZACIÓN) Is Null));

I need to be able to update the [Id] field in the [Importación_DT_Salida] table with the values from the [Id] field in the [Deposito_Temporal_Entrada] table so long as both values are equal.

Does anyone have any suggestions on how I can do this since I cannot use the update query.

Thanks for any help.
Peps
 
It is not at all clear why you are using a right join.

Normally you just inner join Deposito_Temporal_Entrada] and [Importación_DT_Salida]. Create the Select query in QBE, run it to see it is working correctly. Now change the query to an Update Query and assign relevant [Importación_DT_Salida] fields equal to corresponding [Deposito_Temporal_Entrada] fields.

 
Sorry, I should mentioned that I got the query running. Since then I've added some more updates:

UPDATE Importaci?n_DT_Salida LEFT JOIN Deposito_Temporal_Entrada ON Importaci?n_DT_Salida.AUTORIZACI?N = Deposito_Temporal_Entrada.Autorizaci?n SET Deposito_Temporal_Entrada.Bultos_Vivo = [Deposito_Temporal_Entrada].[Bultos]-[Importaci?n_DT_Salida].[Bultos], Deposito_Temporal_Entrada.Peso_Vivo = [Deposito_Temporal_Entrada].[Kilos]-[Importaci?n_DT_Salida].[Kilos], Deposito_Temporal_Entrada.Volumen_Vivo = [Deposito_Temporal_Entrada].[Volumen]-[Importaci?n_DT_Salida].[Volumen], Deposito_Temporal_Entrada.Valor_Vivo = [Deposito_Temporal_Entrada].[Valor]-[Importaci?n_DT_Salida].[Valor]
WHERE ((Not (Importaci?n_DT_Salida.AUTORIZACI?N) Is Null));

Sometimes you spend too many hours if front of a monitor you just cant work out some things. All it takes is a good nights sleep....

Your reply is more than appreciated, Thanks - Peps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top