A.D.Tejpal
adtp at touchtelindia.net
Wed May 18 12:04:25 CDT 2005
Calculated Fields based upon Subreports When a subreport has no data, it behaves like a dead report and no event fires (other than a flicker of open event). Even the ReportHeader event fails to fire. As a result, when a calculated field on the main report refers to the contents of a field located on the subreport, it is as if this other field (on the subreport) does not exist. This leads to #Error display in the dependant field on main report. The problem outlined in the preceding para is different from that related to null value. It does not get overcome by use of Nz() function. The remedy lies in incorporating a check for HasData property of the subreport. Typical syntax (for a calculated field on the main report) would be (pl watch for word wrap)- = IIf([SR_A].[Report].[HasData], SR_A("TxtStock"), 0) + IIf([SR_B].[Report].[HasData], SR_B("TxtStock"), 0) The above expression gets the sum of contents of controls named TxtStock in subreports pertaining to controls SR_A and SR_B (acting as containers for the two subreports respectively). Note As an alternative, if the required values are pushed to an unbound control on the main report, from the subreport, by using its parent property, then absence of data in subreport merely results in null value in the affected control (on the main report). The situation can then be handled conveniently by use of Nz() function. (There is no problem of #Error display). A.D.Tejpal -------------- ----- Original Message ----- From: Mark Boyd To: AccessD at databaseadvisors.com Sent: Wednesday, May 18, 2005 03:29 Subject: [AccessD] Referencing Fields in Sub-Reports How can I reference values in textboxes that are located in sub-reports? I have a report (rptMain) with 2 subreports (rptSub1 and rptSub2). Each subreport only contains 1 textbox. I want to grab the values from each textbox in the 2 subreports, and display a total of the values on my main report, rptMain. I can't figure out how to enter the Control Source of the textbox on my main report. With forms, I would just use "Forms!frmMain.frmSub1.Form.txtTextbox + Forms!frmMain.frmSub2.Form.txtTextbox", or something of this nature. I can't figure out how to do this with reports. Any ideas? Thanks, Mark Boyd I/S Supervisor McBee Associates, Inc. 610/964-9680 x15