|
try:
Function Sz(MyFild As String, MyTable As String) As Double
'MyFild 为相乘的字段,MyTable为myfild所在的表
'用法:Call Sz("rice", "A")
Dim Rs As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Dim I As Double
Dim Sql As String
Set Conn = CurrentProject.Connection
Sql = "select " + MyFild + " from " + MyTable + ""
Rs.Open Sql, Conn, adOpenDynamic, adLockOptimistic
I = 1
If Rs.EOF Then
Sz = 0
Exit Function
End If
Do While Not Rs.EOF
I = I * Rs.Fields(0)
Rs.MoveNext
Loop
Sz = I
Set Rs = Nothing
Set Conn = Nothing
End Function |
|