M
m stroup
I am using a form which has several calculated fields. I am trying to
display when the next maintenance is due on an engine after the day's entry
is made. It seemed to be working fine when I had data in the "tblflights"
table, but when I deleted the records there and tried again, the calculated
results were not correct.
thanks for any help you can offer.
Dim NextSPMaint As Double
NextSPMaint = DLast("[EngineHrs]", "tblEngineMaintenance", _
"[SerialNumber] = EngineTxt.Value And [Type] = 'Spark Plug'") + 40
txtNextSPMaint.Value = NextSPMaint
If DCount("Engine", "tblFlights", "[Engine] = [EngineTxt]") = 0 Then
TotalEngHrs.Value = TxtEnginetime.Value + DLookup("[EngineHours]", _
"[tblEngine]", "[SerialNumber] = [EngineTxt]")
Else
TotalEngHrs.Value = DSum("([Land] - [EngineStart]) * 24",
"tblFlights", _
[Engine] = EngineTxt.Value) + TxtEnginetime.Value + _
DLookup("[EngineHours]", "[tblEngine]", "[SerialNumber] =
[EngineTxt]")
End If
txtSPMaint.Value = NextSPMaint - TotalEngHrs.Value
If NextSPMaint - TotalEngHrs.Value < 2 Then
txtSPMaint.ForeColor = vbRed
Else: txtSPMaint.Value = vbBlack
End If
-
Teach me to fish! Thanks for the help.
Pax, M
display when the next maintenance is due on an engine after the day's entry
is made. It seemed to be working fine when I had data in the "tblflights"
table, but when I deleted the records there and tried again, the calculated
results were not correct.
thanks for any help you can offer.
Dim NextSPMaint As Double
NextSPMaint = DLast("[EngineHrs]", "tblEngineMaintenance", _
"[SerialNumber] = EngineTxt.Value And [Type] = 'Spark Plug'") + 40
txtNextSPMaint.Value = NextSPMaint
If DCount("Engine", "tblFlights", "[Engine] = [EngineTxt]") = 0 Then
TotalEngHrs.Value = TxtEnginetime.Value + DLookup("[EngineHours]", _
"[tblEngine]", "[SerialNumber] = [EngineTxt]")
Else
TotalEngHrs.Value = DSum("([Land] - [EngineStart]) * 24",
"tblFlights", _
[Engine] = EngineTxt.Value) + TxtEnginetime.Value + _
DLookup("[EngineHours]", "[tblEngine]", "[SerialNumber] =
[EngineTxt]")
End If
txtSPMaint.Value = NextSPMaint - TotalEngHrs.Value
If NextSPMaint - TotalEngHrs.Value < 2 Then
txtSPMaint.ForeColor = vbRed
Else: txtSPMaint.Value = vbBlack
End If
-
Teach me to fish! Thanks for the help.
Pax, M