-
Dear VB users,
In the next rows you can calculate via SQL the average & the sum.
But where can I find the result?
'Calculate the average
Set RS = DB.OpenRecordset("select avg(MyField) from MyTabel") '
RS.MoveLast
'RESULT ? ? ? ? ? ? ? ? ?
'Calculate the sum
Set RS = DB.OpenRecordset("select sum(MyField) from MyTabel ") '
RS.MoveLast
'RESULT ? ? ? ? ? ? ? ? ?
Thanks for your information.
Nice regards,
Michelle.
-
You can use
Set RS = DB.OpenRecordset("select avg(MyField) as Avgval from MyTabel") '
RS.MoveLast
msgbox rs!avgval
'or msgbox rs.fields(0).value
Set RS = DB.OpenRecordset("select sum(MyField) as Sumval from MyTabel ") '
RS.MoveLast
msgbox rs!Sumval
-
Hello sarun,
Thanks for your information.
Michelle.