Private Sub cmdRefresh_Click()
Dim rs As DAO.Recordset
Dim db As Database
If IsNull(Me.cmbyear) Then
MsgBox "you must choose a year", vbOKOnly, "Year required"
Me.cmbyear.SetFocus
End If
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Month([casedate])as cMonth, Sum(HD.Onvent) AS Onvent, HD.Hosp, Sum(HD.TotalDeath) as TotalDeath, Sum(HD.TE_Timely) as TE_Timely, " & _
"Sum(HD.EyeDonorCnt) as EyeDonorCnt, Sum(HD.TissDonorCnt) as TissDonorCnt, Sum(HD.DonorCnt) as DonorCnt, Sum(HD.DCD) as DCD, Sum(HD.CNR) as CNR, " & _
"Sum(HD.Timely) as Timely, Sum(HD.Imminent) as Imminent, Sum(HD.Eligible) as Eligible, Sum(HD.OrgTx) as OrgTx, " & _
"Sum(HD.txHeart) as txHeart, Sum(HD.txLiver) as txLiver, Sum(HD.txPanc) as txpanc, Sum(HD.txIntestine) as txIntestine, Sum(HD.DonorOther_Neither) as DonorOther_Neither, " & _
"Sum(HD.txLfKidney) as txLfKidney, Sum(HD.txRtKidney) as txRtKidney, Sum(HD.txLfLung) as txLfLung, Sum(HD.txRtLung) as txRtLung " & _
"FROM dbo_HD_Summary HD " & _
"GROUP BY Month([casedate]), HD.Hosp " & _
"HAVING [HD.Hosp]= '" & Me.cmbHospital & "'")
Do While Not rs.EOF
Me.Controls("int" & Format(rs!cMonth, "00") & "_TotalReferrals") = Nz(rs!OnVent, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_AllDeaths") = Nz(rs!Totaldeath, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_TETimely") = Nz(rs!TE_Timely, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_EyeDonors") = Nz(rs!EyeDonorCnt, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_TissueDonors") = Nz(rs!TissDonorCnt, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_OrganReferrals") = Nz(rs!OnVent, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_OrganTimeliness") = Nz(rs!Timely)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Imminent") = Nz(rs!Imminent, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Eligible") = Nz(rs!Eligible, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_OTPD") = Nz(rs!OrgTx, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_OrganDonors") = Nz(rs!DonorCnt, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_DCD") = Nz(rs!DCD, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_CNR") = Nz(rs!CNR, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Heart") = Nz(rs!txHeart, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Liver") = Nz(rs!txLiver, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Pancreas") = Nz(rs!txPanc, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Intestine") = Nz(rs!txIntestine, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Kidneys") = Nz(rs!txLfKidney, 0) + Nz(rs!txRtKidney, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_Lungs") = Nz(rs!txLfLung, 0) + Nz(rs!txRtLung, 0)
Me.Controls("int" & Format(rs!cMonth, "00") & "_DonorNeither") = Nz(rs!DonorOther_Neither, 0)
rs.MoveNext
Loop
MsgBox "Refresh is complete...check that data", vbInformation, "REFRESH COMPLETE!!"
rs.Close
Set rs = Nothing
End Sub