If table Hydrants includes a list of all hydrants, regardless of whether they have maintenance records, then do a LEFT JOIN like this -
Code:
SELECT
TH.[Hydrant No],
TH.Location,
NZ(TM.[Paint OK],""),
NZ(TM.[Needs Paint],""),
NZ(TM.Touchup,""),
NZ(TM.Repainted,""),
NZ(TM.[Last Paint Date],"NEVER"),
NZ(TM.Crew,"")
FROM
Hydrants AS TH
LEFT JOIN
Maintenance AS TM
ON TH.[Hydrant No] = TM.[Hydrant No]
WHERE
(((TM.[Last Paint Date]) Is Null))
ORDER BY
TM.[Hydrant No];
Something just seems odd to me about the design assumptions here.
[Paint Ok] and [Needs Paint] seem like two Boolean variables, and seem mutually exclusive.
Likewise, [Touchup] and [Repainted] seem like past maintenance actions, so they might be dates of that activity, or they might be mutually explucive Boolean variables to describe what happened at the [Last Paint Date].
The problem is that, if the first two are inspection results, then there needs to be an inspection date somewhere, and the only place to put it is in the [Last Paint Date] field.
If all fields those represent things that happened at different times, then [Crew] would just be the last people to touch the record...
On the other hand, if each hydrant can have multiple maintenance records, then only one of the four fields would be filled true, the others false.
I'm thinking that what you have here is an unnormalized form, that probably should look like
Code:
tblMaintActions
PK AutoNumber Key
HydrantNo FK to Hydrant
MaintDate Date
MaintType Text (Inspection or Painting - could also be a code)
MaintResults Text (Paint OK or Needs paint for Inspections, Touchup or Repainted for Painting - could also be a code)
MaintNotes Text (a place for notes)