|
The #Error message occurs when there are no underlying records in the table or query the report is based on (i.e. an empty recordset). The most likely field this will happen in is an unbound field that performs a calculation on another field, i.e. Sum. If there are no records to perform the calculation on then the #Error message is displayed. In this case you may rather display a 0, if there is no data, as it makes the report a bit tidier.
You can do this by checking whether the report has any data in it or not by evaluating the HasData property and then combining it with the IIF function. The HasData property returns one of three values:
-1 = Bound report with records
0 = Bound report with no records
1 = Unbound report
The example below shows how to use this in an unbound text box that sums the field [Goals] in the report [Report1]. If there is data the sum of the field [Goals] is displayed, otherwise 0 is displayed.
Do you like this tip? Subscribe to my weekly Newsletter to receive tips
weekly via email.
Click Here to subscribe.
|