473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Report totals says, "#Error" when i print. But looks perfectly fine in Printview

govnah
9
Hi mighty fine people,

I have a report with two sub-reports attached. The Main report calculates the totals of the two sub-reports.

The problem i am having is that when i open the report, it looks perfectly fine; the totals are calculated perfectly. But when i actually print the report, the total field shows #Error on the printed paper.

I was reading around and it looks like, and i've verified that the reason for this is because one of my sub-forms has null record set. When both sub-reports generate records, it prints the totals without "#Error".

One sub-report will be empty from time to time.

How can i allow my totals to still calculate with just one sub-form when the other is empty?

Thank You
Jun 4 '10 #1
7 1958
NeoPa
32,556 Expert Mod 16PB
That depends very heavily on how you're doing what you're doing. Perhaps if you give some details of what is erroring and where we can help you.
Aug 6 '10 #2
dsatino
393 256MB
Definitely need more details, but in general you need to test for a null result before the report prints(preview) and tell it what to do if the result is null.
Aug 6 '10 #3
NeoPa
32,556 Expert Mod 16PB
Reports have an event On No Data that can be used to test this. The stub of the event procedure looks like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.  
  3. End Sub
Setting Cancel to True before exiting it will cause the report not to run. This may not be what you need. It's hard to tell from the little information you've shared.
Aug 6 '10 #4
govnah
9
Thank You Guys for taking time out to help.

So sorry, for the lack of details.

I thought of a different workaround to the problem. I decided to add a default record to the sub-report so that there is always data in the sub-report to show. Also i think the problem was caused because the results from the sub-reports were not calculated with Nz(). I didn't know Nz(Sum(Price),0) is a way better solution than Sum(Price).

I have definitely learnt a new trick from that experience.



However, Sir NeoPa,
Regarding On No Data event.

If i had a sub-report that sometimes produces No Data, could i use this event to not include the sub-report and still be able to calculate the Grand Total without Error?

Example:

My main report has a final price from calculating the total prices from the two sub-reports.

MainReport:
txtGrandTotal = SubRpt1_Total + SubRpt2_Total


If SubRpt1_Total has No Data, will it still be possible to calculate txtGrandTotal?


Thank You
Aug 6 '10 #5
NeoPa
32,556 Expert Mod 16PB
I'm sorry to disappoint, but my experience there is limited. I only have one example in my whole portfolio of using a subreport. I never reference any of the controls therein from the main report either. Unfortunately I cannot even play around as the data has gone so I cannot even run it now :(

My guess though, is that a missing subreport would result in your formula failing due to the invalid reference.

Another thing to consider is what you actually want from this. When a report is run in a standard way it makes sense to abort if there is nothing to show. That is all stand-alone. When a report is integrated into another report as a subreport, then the situation is different. Failing to run the subreport doesn't allow the operator to start again as the main report is run anyway. All that happens is you are left with an ugly hole.

What would you want it to do in those circumstances? That's the question you need to ask yourself first. I expect the answer would be to run the report and include the total value, that must evaluate to zero rather than a Null or #Error result.

When you know what your plan is, we can help you to execute that plan.
Aug 6 '10 #6
govnah
9
Thank you NeoPa,

Yes please, i would like it to give the sub-report's total result which evaluates to zero when there is no data.

Quick question, when the sub-report has no data, is there literally a hole left in the main report? or the hole will be filled with the other sub-report?

Example:
On the main report, subRpt1 has no data therefore it doesn't run. Will subRpt2 move up and occupy the space that subRpt1 would have taken?

Thank You
Aug 6 '10 #7
NeoPa
32,556 Expert Mod 16PB
You want the report to run and have a control whose value is zero. In that case I suggest a report footer be used that contains a control that has :
Expand|Select|Wrap|Line Numbers
  1. =Nz(Sum([txtVal]),0)
or such like as the formula. Again, I'm afraid I'm not in a position to check this out for you as I have no materials, but try that and see what occurs.

As for the report being cancelled, I expect the result would depend on the design of your main report and how the subreport control is set up. You could probably do it either way, but I'd need to play to see how.

Sorry, I did mention this wasn't one of my more experienced areas :(
Aug 6 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: noname | last post by:
I have a query that subtracts this months mileage from last months, then divides that mileage value by the fuel used by the vehicle to figure this months miles per gallon. Whenever one of the...
2
by: christianlott1 | last post by:
I'm doing a replace function on a phone number field: Expr1: NZ(ReplaceText(),"") and it converts most of them but for others I get this "#Error" in the fields. Since I will need to do a join...
2
by: Martin Z | last post by:
I'm using the TableAdapterHelper to set the connection and transaction properties on all the commands of all my typed table adapters.... I've checked at the time of the error and all the commands...
6
AccessIdiot
by: AccessIdiot | last post by:
Hi all, I have this function in an unbound textbox on my form: =DSum("SpecimenCount","tbl_Specimen_Entrainment","Entrainment_ID = " & ) It does a wonderful job, except when I go to a new...
8
by: amievil | last post by:
Hello. I'm devloping MFC program and found something weird happening. When I compile it with "debug mode", it compile fine, and runs fine. however, when I compile with "release mode", I get...
4
by: dstorms | last post by:
Hi, I'm trying to create a form with a list box with 2 columns and a button that opens the selected record in the appropriate form. In the sample below, the first column lists the type of equipment...
4
by: lostlander | last post by:
In ARMCC, and Microsoft C, when i use a function which is never defined or delared, it gives out a warning, not a compiling error? why? (This leads to a bug to my program since I seldom pay much...
6
kcdoell
by: kcdoell | last post by:
Hello: I three fields on a continuous form: , & On the same form I have an unbound text box with the following formula in the control source: =Sum(IIf(=50,,0)) This worked great.
2
by: Lewe22 | last post by:
I am wondering if anyone knows a way of representing a "#Error" shown on a form in a text box as 0? I realise this is not the most logical thing to do but does anyone know if it's possible....
14
Frinavale
by: Frinavale | last post by:
I've been trying to test my web application using Internet Explorer 8 (release candidate 1) and have been experiencing some major problems. I'm hoping you can help me with this one. I have a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.