All those INNER JOINS mean that there must be a record in every table that
relates to the row to be returned.
FROM t_PowerEquipStandard INNER JOIN
(t_PowerSystemInfo INNER JOIN
(t_PowerBoxInfo INNER JOIN
t_Busrows
ON t_PowerBoxInfo.BoxBussConnect =t_Busrows.BUSROW)
ON t_PowerSystemInfo.SystemBoxLocation = t_PowerBoxInfo.BoxLocation)
ON t_PowerEquipStandard.Model_Number = t_PowerSystemInfo.CompmentItem
Which means if even if there is a value in t_busrows and there is no related
record in t_powerBoxInfo then there won't be any row returned
You might try changing all the INNER JOINs to RIGHT JOINS and see if that
solves your problem. A right join means that all records on the right side of
the join will be returned and if there are matching records on the left side
of the join the data from those records will be returned. If there is no
matching record then nulls will be returned in the columns for that table.
There are also LEFT JOINS that work similarly except the logic is flipped.
So try editing the FROM clause to read as follows.
FROM t_PowerEquipStandard RIGHT JOIN
(t_PowerSystemInfo RIGHT JOIN
(t_PowerBoxInfo RIGHT JOIN
t_Busrows
ON t_PowerBoxInfo.BoxBussConnect =t_Busrows.BUSROW)
ON t_PowerSystemInfo.SystemBoxLocation = t_PowerBoxInfo.BoxLocation)
ON t_PowerEquipStandard.Model_Number = t_PowerSystemInfo.CompmentItem
If you do this then you should see at least the information from the t_busrows
table that matches your criteria.
You can also speed things up a bit by using a WHERE clause instead of a HAVING
clause and since you are not doing any aggregation, use the DISTINCT keyword
and drop the GROUP BY section
Bottom line try the following SQL
SELECT DISTINCT t_Busrows.BUSROW, t_Busrows.CIRCUIT, t_Busrows.PANEL
, t_Busrows.PnlLoc, t_Busrows.MFG, t_Busrows.TRIP
, t_PowerBoxInfo.BoxLocation
, t_PowerSystemInfo.CompmentItem, t_PowerEquipStandard.Mean_Amps
, t_PowerSystemInfo.ComponentPhaseA, t_PowerSystemInfo.ComponentPhaseB
, t_PowerSystemInfo.ComponentPhaseC
, ([Mean_Amps]*[ComponentPhaseA])/100 AS PhaseALoad
, ([Mean_Amps]*[ComponentPhaseB])/100 AS PhaseBLoad
, ([Mean_Amps]*[ComponentPhaseC])/100 AS PhaseCLoad
, t_PowerEquipStandard.Manufacture, t_PowerEquipStandard.Description
, t_PowerSystemInfo.SystemNumber
, t_PowerSystemInfo.SystemComponentAlpha
, t_PowerSystemInfo.SystemName
, t_PowerSystemInfo.DualPower, t_Busrows.mAMPA, t_Busrows.mAMPB
, t_Busrows.mAMPC, t_Busrows.mDATE
FROM t_PowerEquipStandard RIGHT JOIN (t_PowerSystemInfo RIGHT JOIN
(t_PowerBoxInfo RIGHT JOIN t_Busrows
ON t_PowerBoxInfo.BoxBussConnect =t_Busrows.BUSROW)
ON t_PowerSystemInfo.SystemBoxLocation = t_PowerBoxInfo.BoxLocation)
ON t_PowerEquipStandard.Model_Number = t_PowerSystemInfo.CompmentItem
WHERE t_Busrows.BUSROW Like "*" & [What Buss Row?] & "*"
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
OK, here’s the complete SQL statement (thanks for telling me how to get it –
as I mentioned, I’m still pretty inexperienced but trying to learn):
snip
Now, I think the HAVING statement is set up to make the parameter entry as
flexible as possible because it has wildcard characters at both ends. The
[quoted text clipped - 41 lines]