Hello Everyone,
I need to generate a report that shows the number of NVG landings in the previous 60 days and how many days remaining before they become uncurrent. Each pilot must perform a minimum of 6 NVG landings every 60 days.
I have 2 queries for this - 1) totals the landings in the previous 60 days; 2) the other shows each NVG entry by pilot, date, # landings for that flight entry.
The code below works somewhat but not totally. It gives me the total number of landings but the days remaining is flawed. For instance:
7-16-11 to 9-13-11 (60 day window)
Pilot A flew 7-16-11 = 2 landings
8-8-11 = 8 landings
9-2-11 = 9 landings
9-10-11 = 3 landings
The output is Pilot A = 22 landings * 0 days remaining. Because of course my code is using the first date in the query of 7-16-11. I know this but couldn't figure the correct way.
So I need to evaluate from the most recent and work backwards to get the correct number of days remaining. Remember they need 6 in 60.
Any guidance/help would be appreciated as always.
Thanks.
Steve (coding for fun / pilot for work)
I need to generate a report that shows the number of NVG landings in the previous 60 days and how many days remaining before they become uncurrent. Each pilot must perform a minimum of 6 NVG landings every 60 days.
I have 2 queries for this - 1) totals the landings in the previous 60 days; 2) the other shows each NVG entry by pilot, date, # landings for that flight entry.
The code below works somewhat but not totally. It gives me the total number of landings but the days remaining is flawed. For instance:
7-16-11 to 9-13-11 (60 day window)
Pilot A flew 7-16-11 = 2 landings
8-8-11 = 8 landings
9-2-11 = 9 landings
9-10-11 = 3 landings
The output is Pilot A = 22 landings * 0 days remaining. Because of course my code is using the first date in the query of 7-16-11. I know this but couldn't figure the correct way.
So I need to evaluate from the most recent and work backwards to get the correct number of days remaining. Remember they need 6 in 60.
Any guidance/help would be appreciated as always.
Thanks.
Steve (coding for fun / pilot for work)
Code:
Dim nvgdate As Variant
Dim formlevel As Variant
numpilots = DCount("[Pilot_Name]", "qry_Pilot_NVG") - 1
For X = 0 To numpilots
formlevel = Me.lstNVGLandings.Column(0, X)
'Get 1st NVG date
nvgdate = DLookup("[Log_Date]", "qry_Pilot_NVG_date", "Pilot_Name =" & Chr(34) & formlevel & Chr(34))
nvgpilot = DLookup("[Pilot_Name]", "qry_Pilot_NVG", "Pilot_Name=" & Chr(34) & formlevel & Chr(34))
nvglandings = DLookup("[PilotNVG]", "qry_Pilot_NVG", "Pilot_Name=" & Chr(34) & formlevel & Chr(34))
backdate = Date - 59
numdays = nvgdate - backdate
MyPos = InStr(nvgpilot, ",")
pilot = Left(nvgpilot, MyPos)
'numdays = format
If IsNull(numdays) = False Then
If nvglandings > 5 Then
lstCombine.AddItem (pilot & nvglandings & " HNVGO ** " & numdays & " days remaining"), X
Else
lstCombine.AddItem (pilot & "NVG UNCURRENT"), X
End If
Else
'lstPilotNVG.AddItem (medic & totalnvglandings)
End If
'--------------------
Next X