This should work in Access 2003, provided it is a bound form.
=[Form].[RecordsetClone].[RecordCount]
If it's a subform that contains the data, you need to refer to the subform:
http://allenbrowne.com/casu-04.html

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
On 22 Jan, 14:16, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> See:
> Avoid #Error in form/report with no records
[quoted text clipped - 21 lines]
>
> - Show quoted text -
None of those options work. ([Form].[Recordset].[RecordCount] gives
#name also. I am using Access 2003.
Stapes - 22 Jan 2008 15:32 GMT
> This should work in Access 2003, provided it is a bound form.
> =[Form].[RecordsetClone].[RecordCount]
[quoted text clipped - 39 lines]
>
> - Show quoted text -
I think the problem is, if there are no records, the field name
itself, SumOfTotalSpend, isn't recognised - hence the #Name? error, in
the following sentence:
=IIf([NUM_Recs]=0,0,Sum(NZ([SumOfTotalSpend],0)))
Where NUM_Recs is the record count.
I could not get that to work properly either, so I have done this:
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim NUM_Total As Integer
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.MoveLast
NUM_Total = rst.RecordCount
Me.NUM_Recs = NUM_Total
exit_Form_Load:
Exit Sub
Err_Form_Load:
If Err.Number = 3021 Then
Me.NUM_Recs = 0
Me.TXT_Total.ControlSource = "0"
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub