|
笨办法:一个一个相加,不用sum()
With rs
.Open "ExpnDTL10101_Jul", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
For a = 0 To .Fields.Count - 1
Bj = Left(.Fields(a).Name, 3)
If Bj = "A20" Or Bj = "F20" Or Bj = "P20" Then
If Bj = "P20" Then
flds1 = flds1 & "+" & "[" & .Fields(a).Name & "]"
Else
flds = flds & "+" & "[" & .Fields(a).Name & "]"
End If
End If
Next
.Close
End With
flds = Right(flds, Len(flds) - 1)
flds1 = Right(flds1, Len(flds1) - 1)
striSQL = "SELECT acct,AcctDescription ," & flds & " AS TtlYrFC, " & flds1 & " AS TtlYrPP FROM ExpnDTL10101_Jul "
Set qdf = CurrentDb.QueryDefs("ExpnDtlQry")
qdf.Sql = striSQL
qdf.Close
Set qdf = Nothing
DoCmd.OpenQuery "ExpnDtlQry" |
|