I am using Access 2003. I am setting up a form where a user selects a Clinic or Ward, beginning date, and ending date, and the form outputs the averages of a few fields based on that criteria. I have come up with this so far for the query -
Dim strSQL As String
strSQL = ""
If chkClinic.Value = -1 Then
strSQL = "Select avg(Courtesy), avg(Timeliness), avg(Confidence), avg(Privacy), " & _
"avg(Sensitivity), avg(Cleanliness), avg(Advice), avg(Overall) FROM tblScores " & _
"WHERE Clinic = '" & Me!cboClinic.Value & "' AND Date >= " & Me!txtBegin.Value & _
" AND Date <+ " & Me!txtEnd.Value
Else
strSQL = "Select avg(Courtesy), avg(Timeliness), avg(Confidence), avg(Privacy), " & _
"avg(Sensitivity), avg(Cleanliness), avg(Advice), avg(Overall) FROM tblScores " & _
"WHERE Ward = '" & Me!cboWard.Value & "' AND Date >= " & Me!txtBegin.Value & _
" AND Date <+ " & Me!txtEnd.Value
End If
But I'm having trouble getting the data pulled from that query into the proper text boxes (txtCourtesy, txtTimeliness, etc.). I've been pulling it into a recordset but I can't seem to get anything to work right. I think I just don't really have a grasp on how to manipulate a recordset yet.
Also - there is another category, "Handwashing," in addition to these others. Whereas the other factors are on a 0-5 scale, so an average works fine, Handwashing is boolean. I would like to calculate Handwashing so that the query returns a percentage of numerator "true" and denominator of total records. I imagine I'll be able to do this part pretty easily once I figure out the other part.