Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Reports: Handle Null values in fields

Author(s)
Arvin Meyer

If you're using a field as part of an expression in another control on the report, a Null value in the field can cause errors.

An easy way to handle such errors is to force the field to Zero using a custom function if it contains a Null value.  For example, I use the following function:

'******** Code Start *********
Function ErrorAvoid(n As Variant) As Variant
  On Error GoTo Trap
  ErrorAvoid = n
  Exit Function
Trap:    
  ErrorAvoid = 0    
  Resume Next    
  Exit Function
End Function
'******** Code End *********

Then use it in a calculated text boc

=(txtAnyField)+ErrorAvoid(Reports!RptName!SubRptName.Report!txtSubtotal)

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer