Hi,
The forms record source is a table.
The changes I made to your code above is as follows; did I miss anything?
Option Compare Database
Function RunSum(F As Form, KeyName As String, KeyValue, _
FieldToSum As String)
'************************************************* **********
' FUNCTION: RunSum()
' PURPOSE: Compute a running sum on a form.
' PARAMETERS:
' F - The form containing the previous value to
' retrieve.
' KeyName - The name of the form's unique key field.
' KeyValue - The current record's key value.
' FieldToSum - The name of the field in the previous
' record containing the value to retrieve.
' RETURNS: A running sum of the field FieldToSum.
' EXAMPLE: =RunSum(Form,"ID",[ID],"Amount")
'************************************************* **********
Dim rs As DAO.Recordset
Dim Result
On Error GoTo Err_RunSum
' Get the form Recordset.
Set rs = frm_Reclamation Info.RecordsetClone
' Find the current record.
Select Case rs.Fields(RecAcctID).Type
' Find using numeric data type key value?
Case DB_INTEGER, DB_LONG, DB_CURRENCY, _
DB_SINGLE, DB_DOUBLE, DB_BYTE
rs.FindFirst "[" & RecAcctID & "] = " & KeyValue
' Find using date data type key value?
Case DB_DATE
rs.FindFirst "[" & RecAcctID & "] = #" & KeyValue & "#"
' Find using text data type key value?
Case DB_TEXT
rs.FindFirst "[" & RecAcctID & "] = '" & KeyValue & "'"
Case Else
MsgBox "ERROR: Invalid key field data type!"
GoTo Bye_RunSum
End Select
' Compute the running sum.
Do Until rs.BOF
Result = Result + rs(RecPendAmt)
' Move to the previous record.
rs.MovePrevious
Loop
Bye_RunSum:
RunSum = Result
Exit Function
Err_RunSum:
Resume Bye_RunSum
End Function
The second quote should be placed in the subform's record source or a new field's record source. I don't understand how this will work?
Thanks,
NLR