• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

WHEN REPLACED DSUM WITH TSUM - how to use expression instead of the name of the field

Hi, I have such problem: I have to create an application with MS Access, and I found that using the DSUM function is very slow, in order to make the process of data faster I red about replacing DSUM with other function - you called it TSUM. Anyway the TSUM function uses three parameters ,the first one is the name of the field, but in my case it is not a field,but expression and the function doesn't work.Do you have any idea how this problem can be solved? in my case:
tIZRAZ_FRZ = DLookup("[FRZ]", "ZAPD")
tFRZ = DSum(tIZRAZ_FRZ, "ZAPNEW", "[NOMER] = " & RS!NOMER)
Thanks,Katia
0
katia_ibs
Asked:
katia_ibs
  • 2
1 Solution
 
frankyteeCommented:
TSUM is not a valid Access function, create a recordset instead of the DSUM
0
 
frankyteeCommented:
eg:
    Dim tIZRAZ_FRZ As String 'whatever data type
    Dim tFRZ As Double 'whatever data type
    Dim d As DAO.Database, r As DAO.Recordset, sql As String, rs As DAO.Recordset      
    Set d = CurrentDb
    '... whatever code to get rs!nomer
    Set rs = d.OpenRecordset("whatever sql")    '....then go to whatever record
    tIZRAZ_FRZ = DLookup("[FRZ]", "ZAPD") 'you are missing an argument here, the criteria    
    sql = "select sum(" & tIZRAZ_FRZ & ") as mySUM from zapnew where [nomer] = " & rs!nomer 'whatever
    Set r = d.OpenRecordset(sql)
    If r.EOF Then
        MsgBox "record " & rs!nomer & " does not exist!", vbExclamation
    Else
        r.MoveFirst
        tFRZ = r!mySum
        MsgBox "value is " & tFRZ
    End If

    Set d = Nothing
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now