Share via

#error in Access

Anonymous
2010-07-30T21:00:03+00:00

I am running a report that attempts to manipulate data produced by a query. When the query does not return any data, my report fileds that perform calculations show #Error. Is there a way to supress that result so that either nothing comes up or the fields show blank? Thank you.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-07-30T22:38:38+00:00

You'll get an error if you try to reference a control on a subform without any records.  Try the IsError function:

IIf(IsError([MyField]),0,[MyField]).

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-07-31T17:34:52+00:00

    Thanks Scott. I used the IsError solution on the report because of the number of calculations involved. In this case I would have needed to create too many query calculations, whereas they were already in the reports (for the most part). Thanks again.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2010-07-31T12:11:44+00:00

    You may also be better off trying to include that field in your report's underlying query, rather than doing it directly on the Report. This is generally more performant, and will eliminate the #Error issue. To do that, just add a new Column to your query and use your IIF construct. In the Name row of a blank column:

    MyNewField: IIf(#10/1/2010#=[date1],"IN",IIf(#10/1/2010# Between [date1] And [date2],"ON")))

    Now your query will have a new field named "MyNewField", and you can include that on your report.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-07-30T22:04:07+00:00

    Bill, I am working with some dates in this manner.

    The query calculates this for an October report-

    for a field called [date1], the query specifies <=#10/30/2010# in criteria

    for a field called [date2], the query specifies ,>=#10/1/2010# in criteria

    As a result, if there is a date in from another month, it isn't shown in the results.

    The report wants to use query with this expression -

    = IIf(#10/1/2010#=[date1],"IN",IIf(#10/1/2010# Between [date1] And [date2],"ON")))

    When there is no data, the report shows #error in that field.

    Any thoughts?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-07-30T21:35:30+00:00

    You can check the value of the field used in the calculation and substitute a logical value if it is null.

    For instance using this as a ControlSource:

    =IIf(IsNull(MyField) = False, MyField * 100, 0)

    The IIF() function takes 3 arguments: the expression to test, the return if true, and the return if false.

    Capeesh?


    Bill Mosca, MS Access MVP

    http://www.thatlldoit.com

    http://mvp.support.microsoft.com/profile/Bill.Mosca

    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Was this answer helpful?

    0 comments No comments