thread702-1608030
I would really love to use the function provided by MajP called dSumRecordset, however, I cannot get it to work? I am using Access 2016. I put in another function with a break point on the first line to ensure vba was triggering. The function I wrote is triggering but dSumRecordset is not. The control that contains the formula is giving #Name? error. Any ideas? Here's the code:
and here is the call: =mydsum("[FY+2BaselineGvt]",[me].[RecordsetClone],"[RP_Program]='A'")
Thank you in advance!!
Jessica
I would really love to use the function provided by MajP called dSumRecordset, however, I cannot get it to work? I am using Access 2016. I put in another function with a break point on the first line to ensure vba was triggering. The function I wrote is triggering but dSumRecordset is not. The control that contains the formula is giving #Name? error. Any ideas? Here's the code:
Code:
Public Function MyDSum(expr As String, RcrdSet As DAO.Recordset, sz_crtria As String) As Double
On Error GoTo CATCH:
If Not sz_crtria = "" Then
RcrdSet.Filter = sz_crtria
Set RcrdSet = RcrdSet.OpenRecordset
End If
While Not (RcrdSet.EOF)
dSumRecordset = dSumRecordset + (Nz(RcrdSet.Fields(expr), 0))
RcrdSet.MoveNext
Wend
Exit Function
CATCH:
MsgBox Err.Number & " " & Err.Description
End Function
and here is the call: =mydsum("[FY+2BaselineGvt]",[me].[RecordsetClone],"[RP_Program]='A'")
Thank you in advance!!
Jessica