S
scrawny
Hi!
I'm trying to code some SQL in the background that can take a grand
total of weight and place it into an order header table.
The tables are mapped out accordingly:
ORDER_HEADER
linked 1 to many on the Order ID to...
ORDER_DETAILS
linked many to 1 on the Product ID to...
MATERIALS
Order details contains length and quantity whilst materials contains
weight/metre. And the field I want to update is in ORDER_HEADER which
is total_weight.
I have tried the following without success:
Dim SQL_Weight As String
SQL_Weight = "UPDATE [ORDER_HEADER] INNER JOIN ([ORDER_DETAIL] INNER
JOIN [MATERIALS] ON [ORDER_DETAIL].[Product ID] = [MATERIALS].[ID]) ON
[ORDER_HEADER].[ID] = [ORDER_DETAIL].[Order_ID] " & _
"SET [ORDER_HEADER].Total_Weight =
SUM([ORDER_DETAIL].Length * [ORDER_DETAIL].Quantity *
[MATERIALS].Weight) WHERE [ORDER_HEADER].[ID] = " &
OrderForm.Txt_OrderID.Value & ";"
DoCmd.RunSQL SQL_Weight
I'm trying to code some SQL in the background that can take a grand
total of weight and place it into an order header table.
The tables are mapped out accordingly:
ORDER_HEADER
linked 1 to many on the Order ID to...
ORDER_DETAILS
linked many to 1 on the Product ID to...
MATERIALS
Order details contains length and quantity whilst materials contains
weight/metre. And the field I want to update is in ORDER_HEADER which
is total_weight.
I have tried the following without success:
Dim SQL_Weight As String
SQL_Weight = "UPDATE [ORDER_HEADER] INNER JOIN ([ORDER_DETAIL] INNER
JOIN [MATERIALS] ON [ORDER_DETAIL].[Product ID] = [MATERIALS].[ID]) ON
[ORDER_HEADER].[ID] = [ORDER_DETAIL].[Order_ID] " & _
"SET [ORDER_HEADER].Total_Weight =
SUM([ORDER_DETAIL].Length * [ORDER_DETAIL].Quantity *
[MATERIALS].Weight) WHERE [ORDER_HEADER].[ID] = " &
OrderForm.Txt_OrderID.Value & ";"
DoCmd.RunSQL SQL_Weight