Hi Guy's I am struggling to work out how to add calculated fields to recordset results!
Is this better setup in the query statement or setup within the loop, I think i know where i am going wrong, the DMin, DAvg and DMax require a table source instsead of rs.field perhaps ???
I can't for the life of me set this up when i should be able to, should be simple, just can't see it!!!!
Trying to add Min, Avg, Max And a division to recordset email:
Note: full event not added, all are Dimmed per name
Code:
strSQL = "SELECT tblData.TestDATE, tblData.TestTIME, tblData.TestREADING, tblData.TestDOSAGE, tblData.Ratio, tblData.Carbs, tblData.DosageCalc, tblData.TimeOrder " _ & "From tblData " _
& "ORDER BY tblData.TimeOrder DESC;"
Set rs = CurrentDb.OpenRecordset(strSQL)
Do While Not rs.EOF
dblMin = DMin(rs.Fields("Ratio"), , "[Ratio] > " & intMin)
dblMax = DMax(rs.Fields("Ratio"), , "[Ratio] < " & intMax)
dblAvg = DAvg(rs.Fields("Ratio"), , "[Ratio] > " & intMin & " And [Ratio] < " & intMax)
dblAvgCarbs = DAvg(rs.Fields("Carbs"))
dblRatio dblAvgCarbs / dblAvg
strBody = strBody & "<tr>" & _
"<td style='background-color:#F5F5F5'>" & strFS & Format(rs.Fields("TestDATE"), "dddd-dd-mmm-yyyy") & strFE & "</td>" & _
"<td style='background-color:#F8F8FF'>" & strFS & rs.Fields("TestTIME") & strFE & "</td>" & _
"<td style='background-color:#F5F5F5'>" & strFS & rs.Fields("TestREADING") & strFE & "</td>" & _
"<td style='background-color:#F8F8FF'>" & strFS & rs.Fields("TestDOASGE") & strFE & "</td>" & _
"<td style='background-color:#F5F5F5'>" & strFS & Left(dblMin, 4) & strFE & "</td>" & _
"<td style='background-color:#F8F8FF'>" & strFS & Left(dblMax, 4) & strFE & "</td>" & _
"<td style='background-color:#F5F5F5'>" & strFS & Left(dblAvg, 4) & strFE & "</td>" & _
"<td style='background-color:#F8F8FF'>" & strFS & Left(dblAvgCarbs, 4) & strFE & "</td>" & _
"<td style='background-color:#F5F5F5'>" & strFS & Left(dblRatio, 4) & strFE & "</tr>" & "|"
'
rs.MoveNext
Loop
Debug.Print rsbody