Solved Missing calculated fields (1 Viewer)

Seph

Member
Local time
Today, 23:39
Joined
Jul 12, 2022
Messages
72
Good day everyone,

I have a Text Box at the bottom of my report called Subtotal, which acts as a calculated field:

=[InvoiceJobRSF1].[Report]![LabourTotalSum]+[InvoiceJobRSF2].[Report]![CostTotalSum]+[InvoiceJobRSF3].[Report]![TravelTotalSum]

InvoiceJobRSF1, InvoiceJobRSF2 & InvoiceJobRSF3 are Subforms on the report that Subtotal references in its calculations.

It works well, but here's the catch.

Not all reports have values in each subform as some subforms references items not billed to the client.

So when a Subform is "null" the calculation gives a #type error.

Which is most likely due to one missing filed in the SUM used in Subtotal.

Is there a way (perhaps an IIF command) that will essentially "ignore" the missing Subform so the calculated field doesn't break?

Thanks!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:39
Joined
Oct 29, 2018
Messages
21,497
Hi. Try wrapping each value inside the Nz() function.
 

Seph

Member
Local time
Today, 23:39
Joined
Jul 12, 2022
Messages
72
Hi. Try wrapping each value inside the Nz() function.
Thanks for the idea. I tried that.

The physical subform (containing no data) disappears when Report view is switch to Print preview.

So for example, InvoiceJobRSF3 will disappear and then the calculated field can't pin down the data and essentially breaks.

The Nz function wont Null a "field" that essentially doesn't exist.

I'm hoping there is a method for calculated fields to overlook missing fields or replace them.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:39
Joined
Oct 29, 2018
Messages
21,497
Thanks for the idea. I tried that.

The physical subform (containing no data) disappears when Report view is switch to Print preview.

So for example, InvoiceJobRSF3 will disappear and then the calculated field can't pin down the data and essentially breaks.

The Nz function wont Null a "field" that essentially doesn't exist.

I'm hoping there is a method for calculated fields to overlook missing fields or replace them.
Since I can't see your report, why would the subform disappear? Why can't it stay and show as empty? Are you able to share a sample copy of your db to demonstrate the problem? You may end up using some code to produce the total instead.
 

Seph

Member
Local time
Today, 23:39
Joined
Jul 12, 2022
Messages
72
Since I can't see your report, why would the subform disappear? Why can't it stay and show as empty? Are you able to share a sample copy of your db to demonstrate the problem? You may end up using some code to produce the total instead.
The 3 subforms on the report and linked via the primary key, TicketNumber, of the Invoice table.

1664954936728.png


As such, when there are records in each of the tables that reference the TicketNumber they populate data.

This all works perfectly fine in Report View (Fields in red are Invisible SUM fields)

1664954986489.png


As you can see the SUM field for Costs which has a Nz function around it works.

However if you switch to Print Preview, the Subform disappears:

1664955130688.png

I suspect this is due to the Subform having no data to populate. So wrapping the Subtotal in a Nz function doesn't work in this instance.

I can try create a sample .db for you and upload it :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:39
Joined
Sep 21, 2011
Messages
14,365
Is this post a continuation of this one?
 

Seph

Member
Local time
Today, 23:39
Joined
Jul 12, 2022
Messages
72
Is this post a continuation of this one?
Correct
 

Users who are viewing this thread

Top Bottom