Empty subform breaks Print Preview (1 Viewer)

Seph

Member
Local time
Today, 18:32
Joined
Jul 12, 2022
Messages
72
Good day again everyone.

Hope all is well :).

I have a strange one.

I have a report that shows information from 3 Subforms (linked by Primary key). At the end of the report are some Text Fields running calculations.

This is all working smoothly in Report View (Fields in Red are usually hidden SUM fields):

1664193711532.png


However, in Print preview mode the Report excludes the 3rd empty subform Costs and the SUM fields break:

1664193880217.png

Should I be using an IIF command?

Oh and here is the Subtotal calculation field's details:

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

Thank you in advance.
 

bob fitz

AWF VIP
Local time
Today, 17:32
Joined
May 23, 2011
Messages
4,727
Have you tried:
=Nz([InvoiceJobRSF1].[Report]![LabourTotalSum],0)+Nz([InvoiceJobRSF2].[Report]![CostTotalSum],0)+Nz([InvoiceJobRSF3].[Report]![TravelTotalSum],0)
 

Seph

Member
Local time
Today, 18:32
Joined
Jul 12, 2022
Messages
72
Have you tried:
=Nz([InvoiceJobRSF1].[Report]![LabourTotalSum],0)+Nz([InvoiceJobRSF2].[Report]![CostTotalSum],0)+Nz([InvoiceJobRSF3].[Report]![TravelTotalSum],0)
Thanks for your suggestion.

I implemented your solution and then got a new "error" in Print Preview Only

1664197175599.png
 

Seph

Member
Local time
Today, 18:32
Joined
Jul 12, 2022
Messages
72
Seeing as the calculated fields are working in report view. I don't think its a syntax error. I suspect it might have something to do with the Reports On No Data Event possibly?
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:32
Joined
Sep 21, 2011
Messages
14,350
So what code is in that event?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:32
Joined
May 7, 2009
Messages
19,247
you can create a query to Calculate those, then you can Dlookup() the value from the query.
if you can share a sample db then it would be easy to explain.
 

Seph

Member
Local time
Today, 18:32
Joined
Jul 12, 2022
Messages
72
you can create a query to Calculate those, then you can Dlookup() the value from the query.
if you can share a sample db then it would be easy to explain.
Thank you for your advice. Isn't there a simpler method of rectifying this rather than creating queries etc?

I mean it's working perfectly fine in Report View and Layout View. Just not in Print Preview.

I can see why Access is confused, the empty subform disappears when Print Preview is selected due to it being technically Null. Thus the calculated fields break.

Can't we implement a syntax of sorts that stipulates ignore missing Field if not present? In this case the Cost Field:

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

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:32
Joined
May 7, 2009
Messages
19,247
you can try:

=Val([InvoiceJobRSF1].[Report]![LabourTotalSum] & "") + Val([InvoiceJobRSF2].[Report]![CostTotalSum] & "") + Val([InvoiceJobRSF3].[Report]![TravelTotalSum] & "")
 

Seph

Member
Local time
Today, 18:32
Joined
Jul 12, 2022
Messages
72
you can try:

=Val([InvoiceJobRSF1].[Report]![LabourTotalSum] & "") + Val([InvoiceJobRSF2].[Report]![CostTotalSum] & "") + Val([InvoiceJobRSF3].[Report]![TravelTotalSum] & "")
Appreciate the Idea. Sadly no dice. Report View is perfect but Print Preview isn't happy.

1664278417826.png


I know it has to do with the missing Subform because when there is records in it, it works:

1664278542411.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:32
Joined
Sep 21, 2011
Messages
14,350
So could you create a dummy entry 'No data to report'
Are subreports actually needed?, could grouping provide the same info?
 

Users who are viewing this thread

Top Bottom