use of subform values

G

Guest

Hi,

I have a report using a value from a sub-report for calculation as follows:
=(Nz([Text52]))+(IIf(Child0.Report.HasData,Child0.Report.Text55,0))
This work all right.

Now I want to do the same for my form: to use the sub-form data for similar
calculations.
I wrote the following in the control source:
=(Nz([Text52]))+(IIf(Child0.Form.HasData,Child0.Form.Text55,0))
But it doesn't work. :( Asking me for "#Name?"

I checked the names of the fields - they look all right. What else could be
wrong here? Please help me!
 
A

Allen Browne

Forms don't have the HasData property.

Unless your form is based on a read-only query or its AllowAdditions
property has been set to No, you can probably see the new record row in the
query. If so, the text box *does* exist in the subform, and so you can just
refer to it as:
=Nz([Child0].[Form].[Text55], 0)

If the subform does not have the new row, try:
=IIf([Child0].[Form].[RecordsetClone].[RecordCount] > 0,
Nz([Child0].[Form].[Text55], 0), 0)
 
G

Guest

Hi, Allen!

Thank you for answering my stupid questions again! :)

My subform was a read-only form, so I used
=IIf([Child0].[Form].[RecordsetClone].[RecordCount] > 0,
Nz([Child0].[Form].[Text55], 0), 0)
And it worked fine! :))

I just wanted to ask if at the end of the formula the " 0), 0)" - was a
misprint or it MUST have 2 zeros? Because with 1 zero " 0)" it seems to work
just as fine as with 2. :)

Lana
 
A

Allen Browne

There are 2 cases where we forced the value to zero:
- if Text55 is null, given by:
Nz([Child0].[Form].[Text55], 0)

- if the RecordCount is zero, given by:
IIf(there are any records, show the actual value, else show zero)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top