A
Alan T
I got a query to calculate the sum of fields:
SELECT SUM(IIf(isnull(GST)=True,0,GST)) AS TotalGST
FROM tblProject
WHERE ProjectNumber=[ProjectNum];
These are the code I have:
Set qryProjectDef = currDB.QueryDefs("qrySumProjectVariationItems")
qryProjectDef.Parameters("ProjectNum") = Me.txtProjectNumber
Set projectSummarySet = qryProjectDef.OpenRecordset()
If Not projectSummarySet .EOF Then
projectSummarySet .MoveFirst
If projectSummarySet ![totalExGST] <> Null Then
sumGST = projectSummarySet ![totalGST])
End If
End If
The problem is if I add the NULL test, it always give me that is NULL, so
the variable
sumGST never get assigned.
Another weired thing is even the query return empty set, it still can pass
to the MoveFirst statement, I don't understand.
Is it the problem of the field name :
totalGST and
TotalGST ?
SELECT SUM(IIf(isnull(GST)=True,0,GST)) AS TotalGST
FROM tblProject
WHERE ProjectNumber=[ProjectNum];
These are the code I have:
Set qryProjectDef = currDB.QueryDefs("qrySumProjectVariationItems")
qryProjectDef.Parameters("ProjectNum") = Me.txtProjectNumber
Set projectSummarySet = qryProjectDef.OpenRecordset()
If Not projectSummarySet .EOF Then
projectSummarySet .MoveFirst
If projectSummarySet ![totalExGST] <> Null Then
sumGST = projectSummarySet ![totalGST])
End If
End If
The problem is if I add the NULL test, it always give me that is NULL, so
the variable
sumGST never get assigned.
Another weired thing is even the query return empty set, it still can pass
to the MoveFirst statement, I don't understand.
Is it the problem of the field name :
totalGST and
TotalGST ?