L
LarsM
To describe my problem let us assume I have a table ElPowerDistrPanels and a
table ElPowerConsumers. In each record of ElPowerConsumers I have a field
SupplFrom with a reference to a record in ElPowerDistrPanels telling which
distribution panel that particular consumer is supplied from. I also have a
form (view: single form) based on table ElPowerDistrPanels including a sub
form (view: continuous forms) based on table ElPowerConsumers. For each page
of the main form (i.e. for each distribution panel) the sub form indicates
the consumers supplied from that particular panel
([ElPowerConsumers].[SupplFrom]=[ElPowerDistrPanels].[PanelID]). The form
footer of the sub form indicates calculated information like e.g. the sum of
rated powers of the consumers supplied from that panel. In the main form just
below these fields of the sub form I have fields where I indicate information
like e.g. the rated power of the whole panel. In the field in the main form
indicating the rated power of the panel I can manually type the automatically
calculated value "sum of rated power of consumers supplied from this panel"
from the form footer of the sub form. However I would like to automate this
function.
I have tried to make an update query to update table ElPowerDistrPanels so
that rated power of each panel will be equal to the sum of rated powers of
the consumers supplied from that panel. Initially I would expect an update
query like this to work:
UPDATE ElPowerDistrPanels INNER JOIN ElPowerConsumers ON
ElPowerDistrPanels.PanelID = ElPowerConsumers.SupplFrom SET
ElPowerDistrPanels.RatedPower =
DSum([ElPowerConsumers].[RatedPower],[ElPowerConsumers],[ElPowerConsumers].[SupplFrom]=[ElPowerDistrPanels].[PanelID]);
I have tried several modifications of this update query, but none of them
work.
- "Help" indicates that each of the three arguments of the DSum function
must be a string, and the example in "Help" indicate use of quotation marks.
If I do this, I just get a message box indicating "Unknown" without any
explanation. If I omit the quotation marks (as above) the query at least
tries to do something.
- Instead of INNER JOIN I tried to use LEFT JOIN and even RIGHT JOIN, but
that doesn't help me either.
Does anyone have an idea what causes this problem, and what I can do to
solve it?
Actually the above description of my database is not completely correct, but
based on tests carried out on temporary tables I don't think, it makes any
difference to the cause of my problem. Actually I don't have any table
ElPowerDistrPanels. The distribution panels are just represented as records
in the same table as the consumers. The reason for this is, that a sub
distribution panel seen from "below" (consumer) is a distribution panel, but
seen from "above" (main distribution panel) the sub distribution panel itself
is a consumer. A plant can have several levels of sub distribution panels. By
running the update query as many times, as there are levels, I would update
one level each time from below and end up with the rated power of the highest
level main distribution panel i.e. the total electrical power consumption of
the whole plant.
table ElPowerConsumers. In each record of ElPowerConsumers I have a field
SupplFrom with a reference to a record in ElPowerDistrPanels telling which
distribution panel that particular consumer is supplied from. I also have a
form (view: single form) based on table ElPowerDistrPanels including a sub
form (view: continuous forms) based on table ElPowerConsumers. For each page
of the main form (i.e. for each distribution panel) the sub form indicates
the consumers supplied from that particular panel
([ElPowerConsumers].[SupplFrom]=[ElPowerDistrPanels].[PanelID]). The form
footer of the sub form indicates calculated information like e.g. the sum of
rated powers of the consumers supplied from that panel. In the main form just
below these fields of the sub form I have fields where I indicate information
like e.g. the rated power of the whole panel. In the field in the main form
indicating the rated power of the panel I can manually type the automatically
calculated value "sum of rated power of consumers supplied from this panel"
from the form footer of the sub form. However I would like to automate this
function.
I have tried to make an update query to update table ElPowerDistrPanels so
that rated power of each panel will be equal to the sum of rated powers of
the consumers supplied from that panel. Initially I would expect an update
query like this to work:
UPDATE ElPowerDistrPanels INNER JOIN ElPowerConsumers ON
ElPowerDistrPanels.PanelID = ElPowerConsumers.SupplFrom SET
ElPowerDistrPanels.RatedPower =
DSum([ElPowerConsumers].[RatedPower],[ElPowerConsumers],[ElPowerConsumers].[SupplFrom]=[ElPowerDistrPanels].[PanelID]);
I have tried several modifications of this update query, but none of them
work.
- "Help" indicates that each of the three arguments of the DSum function
must be a string, and the example in "Help" indicate use of quotation marks.
If I do this, I just get a message box indicating "Unknown" without any
explanation. If I omit the quotation marks (as above) the query at least
tries to do something.
- Instead of INNER JOIN I tried to use LEFT JOIN and even RIGHT JOIN, but
that doesn't help me either.
Does anyone have an idea what causes this problem, and what I can do to
solve it?
Actually the above description of my database is not completely correct, but
based on tests carried out on temporary tables I don't think, it makes any
difference to the cause of my problem. Actually I don't have any table
ElPowerDistrPanels. The distribution panels are just represented as records
in the same table as the consumers. The reason for this is, that a sub
distribution panel seen from "below" (consumer) is a distribution panel, but
seen from "above" (main distribution panel) the sub distribution panel itself
is a consumer. A plant can have several levels of sub distribution panels. By
running the update query as many times, as there are levels, I would update
one level each time from below and end up with the rated power of the highest
level main distribution panel i.e. the total electrical power consumption of
the whole plant.