hello,
i am trying to get a sum of specified fields as a variable. i tried to do that this way:
Dim db As DAO.Database
Set db = CurrentDb
Dim rst_tmp As DAO.Recordset
Set rst_tmp = db.OpenRecordset("SELECT field FROM table WHERE field=(SELECT SUM(field) FROM table HAVING condition_a='a' AND condition_b='b')")
If Not rst_tmp.EOF Then
rst_tmp.MoveFirst
handle = rst_tmp!field
End If
Set rst_tmp = Nothing
MsgBox (handle)
where handle should contain my sum. But this seem to return and empty recordset. Anybody knows why?
i am trying to get a sum of specified fields as a variable. i tried to do that this way:
Dim db As DAO.Database
Set db = CurrentDb
Dim rst_tmp As DAO.Recordset
Set rst_tmp = db.OpenRecordset("SELECT field FROM table WHERE field=(SELECT SUM(field) FROM table HAVING condition_a='a' AND condition_b='b')")
If Not rst_tmp.EOF Then
rst_tmp.MoveFirst
handle = rst_tmp!field
End If
Set rst_tmp = Nothing
MsgBox (handle)
where handle should contain my sum. But this seem to return and empty recordset. Anybody knows why?