none
Make Unbound text box to default zero RRS feed

  • Question

  • Hi.

    I have a report that sometimes when I sum two columns together

    e.g. Credit-Debit

    On the report, it might generate it has 0.00 while on print preview, it goes blank.

    What can I do to make sure that the report I print preview shows that same record of 0.00 instead of going blank.

    Thanks.

    Wednesday, October 26, 2016 9:59 AM

All replies

  • If either the Credit or Debit can be Null, set the ControlSource property of the text box to:

    =Nz([Credit],0)-Nz([Debit],0)

    Format the text box to whatever currency format you want the value to be presented as.

    Ken Sheridan, Stafford, England

    Wednesday, October 26, 2016 11:06 AM
  • I have done this. This formula is in a subreport of a main report.

    When I query it in the subreport as a standalone, it runs well even if its zero on report view and print preview.

    But when I put it on the main report for it to become a subreport, it runs zero on the report view but when u preview it to print, it goes blank and because other calculations depend on its result, others get the #type error.

    Thanks

    Wednesday, October 26, 2016 12:01 PM
  • Clement, take out these calculations from the report and put in a query.

    The preview view and print view handles events in a different way. To run calculated fields on a print view, you should put it on "Print" event.

    But, if you put the calculated field in a query, you won't need these report events.

    Wednesday, October 26, 2016 3:25 PM
  • The problem is apparently connected with the fact that the report is being opened as a subreport.  Without being able to debug the report its difficult to point to a reason for this.  If the Credit and Debit columns are both in the subreport's recordset it's difficult to see why the computed control should not return a value of zero if this is the result of subtracting the values. In situations like this I would usually do the computation in a computed column in the subreport's RecordSource query rather than in a computed control.  You can then bind a text box control to the computed column.

    Ken Sheridan, Stafford, England


    Wednesday, October 26, 2016 3:30 PM
  • Clement, take out these calculations from the report and put in a query.

    The preview view and print view handles events in a different way. To run calculated fields on a print view, you should put it on "Print" event.

    But, if you put the calculated field in a query, you won't need these report events.


    I don't follow what you are saying here.  A computed control whose ControlSource property is an expression which references other controls in the report or columns in the report's recordset returns the result of the expression however the report is output.  The report events have nothing to do with it.  I would normally do such a computation in the query, but not for this reason.  The advantage of doing so is that the bound control can then be referenced directly, rather than having to repeat the expression, e.g. when aggregating values over a set of rows.

    Ken Sheridan, Stafford, England

    Wednesday, October 26, 2016 3:41 PM