残念ながら、PRODUCT()
Access SQL には、これを可能にする関数はありません。
SELECT PRODUCT([S1]) AS Result FROM [YourTable]
ただし、組み込み関数と同様に、VBA を使用して「独自の」DProduct()
ドメイン集計関数を使用できますDSum()
。
Option Compare Database
Option Explicit
Public Function DProduct(Expr As String, Domain As String, Optional criteria) As Variant
Dim SQL As String, Result As Double
Dim cdb As DAO.Database, rst As DAO.Recordset
On Error GoTo DProduct_Error
Set cdb = CurrentDb
SQL = "SELECT " & Expr & " AS Expr1 FROM [" & Domain & "]"
If Not IsMissing(criteria) Then
SQL = SQL & " WHERE " & criteria
End If
Set rst = cdb.OpenRecordset(SQL, dbOpenSnapshot)
If rst.BOF And rst.EOF Then
DProduct = Null
Else
Result = 1
Do Until rst.EOF
Result = Result * rst!Expr1
rst.MoveNext
Loop
DProduct = Result
End If
rst.Close
Set rst = Nothing
Set cdb = Nothing
Exit Function
DProduct_Error:
DProduct = Null
End Function
質問のサンプルデータを使用したテスト
?DProduct("S1", "YourTable")
6.24666417941851E+24