473,503 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve fields on report from two subreports

294 Contributor
I am trying to pull the SUM() from 2 subreports. It works for one subreport, however not for the other.

What I tried: I Sum() the field in the subreports, so I can refer to that field on the main report. However, for the test case I am trying, there are no records for one of the subreports, so I tried:

Expand|Select|Wrap|Line Numbers
  1. =IIf([PayoutByYrLTTSbRpt].[Report].[NoRecords],0,[PayoutByYrLTTSbRpt].[Report].[LTtotal])
Expand|Select|Wrap|Line Numbers
  1. =IIf([PayoutByYrLTTSbRpt].[Report].[NoData],0,[PayoutByYrLTTSbRpt].[Report].[LTtotal])

And I also tried :

Expand|Select|Wrap|Line Numbers
  1. =IIf([PayoutByYrLTTSbRpt].[Report].[HasData], [PayoutByYrLTTSbRpt].[Report].[LTtotal],0)
Both give me the `#Name?` error when ran. I've tested `=[PayoutByYrLTTSbRpt].[Report].[PytGross]` and it doesn't throw an error in design view, but when ran it does. That tells me it is an issue at run time because the report was able to find the fields I am referring to in design view (thus naming is correct).

For the subreport that is giving me trouble, I have :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.     Private Sub Report_NoData(Cancel As Integer)
  4.     Cancel = True
  5.     End Sub
  6.  
><
May 1 '14 #1
3 1314
zmbd
5,501 Recognized Expert Moderator Expert
because the report was able to find the fields I am referring to in design view (thus naming is correct) (...) and it doesn't throw an error in design view (...)
#Name? Errors only show at run time in the report. Therefor, your logic does not hold to be true.

Both give me the `#Name?` error when ran. I've tested `=[PayoutByYrLTTSbRpt].[Report].[PytGross]
This indicates that the field/control you are refering to does not exsist and this usually do to either a typo or incorrect referenceing.
Now because I'm not exactly sure of where the [PytGross] is located on your form, it's hard to determine what reference you need to make.
For example if you have a OutsideForm, InsideLeft, InsideRight
and for the InsideLeft![textbox1] and for the InsideRight[Textbox2] and InsideRight[Textbox3]
If you wanted the sum of Textbox2 and Textbox3 so show in Textbox1 then in the InsideLeft![textbox1] - in the control source you would need:
Expand|Select|Wrap|Line Numbers
  1. =CLng([Forms]![Outside]![InsideRight]![text2])+CLng([Forms]![Outside]![InsideRight]![text3])
For formatting purposes (I don't want a block of white space where that subreport should have been, this is necessary for each subreport).
One question per thread please
May 1 '14 #2
mcupito
294 Contributor
I'm sorry you interpreted my last sentence as another question - I was stating that the code segment
Expand|Select|Wrap|Line Numbers
  1. Cancel = True
, had it been related to my problem, is necessary.

As far as the meat of your response - The two subreports are set up the exact same way. The field I am summing (PytGross) is a field in the detail section of each subreport. I'm not sure what you mean by InsideLeft InsideRight. PytGross is not a field on a form, but rather a field in the query and on the report.

That being said, I am referencing both fields on each subreport the exact same way, which is why I thought it might have been related to the Cancel = True bit of code on the report where I am not getting any data.

I don't understand why
Expand|Select|Wrap|Line Numbers
  1. =[PayoutByYrLTRSbRpt].[Report].[LRtotal]
works, but
Expand|Select|Wrap|Line Numbers
  1. =[PayoutByYrLTTSbRpt].[Report].[LTtotal]
doesn't.

LTtotal is the field that isn't working, specifically, when being called. It is a textbox with this bit of code in it
Expand|Select|Wrap|Line Numbers
  1. =Sum([PytGross])
as the control source.
[PytGross] is a textbox with name PytGross_txt and Control Source PytGross.

Should I be referencing PytGross_txt or PytGross in the bit of
Expand|Select|Wrap|Line Numbers
  1. =Sum([PytGross])
? Maybe that's where the error lies.
May 1 '14 #3
zmbd
5,501 Recognized Expert Moderator Expert
For example if you have a OutsideForm, InsideLeft, InsideRight
and for the InsideLeft![textbox1] and for the InsideRight[Textbox2] and InsideRight[Textbox3]
If you wanted the sum of Textbox2 and Textbox3 so show in Textbox1 then in the InsideLeft![textbox1] - in the control source you would need:
Three forms
Outside
then subform on the left of hte parent outside form
another subform on the rightside of the parent outside form
...
May 1 '14 #4

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

Similar topics

0
1199
by: Raj | last post by:
I am working on a ASP.NET 1.0 project in VS.NET 2003 and have added a crystal report 9.2 report to it. After building solution when I load the page with this report, it gives me error ...
6
2015
by: Richard Holliingsworth | last post by:
Hello: Thanks for reading this. I would like to build a report (Access 2002) that uses SQL queries to count records in specific groups. I've tried several methods and so far no luck. ...
3
7446
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
0
2370
by: KartoffelKiffer | last post by:
Hello, i have to do a little Crystal Report task, where i need help. I have a mainreport in which are some subreports. The size of the subreports can vary so the subreport which could be bigger...
0
1293
by: khairihusseini | last post by:
I have following code: Private Sub SetDataBaseLocation(ByVal Report As ReportDocument) For Each oConnectionInfo As .IConnectionInfo In Report.DataSourceConnections...
1
5151
by: Brad | last post by:
Thanks for taking the time to read my question. I have a table of data that has Date, Data and Category. I need to show, in a report, each Categories Data by Date. The Date has to be it's own...
13
2176
by: no.mail.pls | last post by:
Hiya, How do i retreive fields with similar values from 2 tables? I tried to use (1) "SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'"; but it retrieves nothing at...
2
2248
by: kfboren | last post by:
I am wondering if someone can help me. I have created 10 tables, 10 queries for the tables and 10 reports from the quearies. The creteria for the queries is the field named "month". I have created...
6
5435
by: Brett Barry: Go Get Geek! | last post by:
Hello, I have a main report with a Record Source, a DateToday table, that has the current Month and Year. I have about 60 queries, each pulling different data via ODBC, that I am creating...
2
2175
by: hmznzr | last post by:
i am using b.net 2005. i am generating a crystal report. but when i work in a different computer i have to set the location of the database of the report before i generate. is their any dynamic way...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.