form with no data

C

ClaudioMadeinItaly

I am trying to put The Sum of a field from a subform on a form. If the form
has records everything works fine, but if it doesn't I get an error message.
I have tried Nz(), IIf(IsNull...), but nothing seems to work.

Can somebody help?
 
S

Steve Schapel

Claudio,

In a standard module, put the following code...

Public Function nnz(testvalue As Variant) As Variant
If Not (IsNumeric(testvalue)) Then
nnz = 0
Else
nnz = testvalue
End If
End Function

Then, in the Control Source of the textbox on your main form, put the
equivalent of this...
=nnz([NameOfSubform]![NameOfTotalsControlOnSubform])
 
T

Tom Wickerath

Hi Claudio,

Perhaps this example will be helpful to you:

Displaying Subtotals and a Grand Total on a Form That
Displays a One-to-Many Relationship
http://www.access.qbuilt.com/html/subtotals.html


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

I am trying to put The Sum of a field from a subform on a form. If the form
has records everything works fine, but if it doesn't I get an error message.
I have tried Nz(), IIf(IsNull...), but nothing seems to work.

Can somebody help?
 
Top