Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: "#Error" Message Using TRIM() Function in Form/Report


View products that this article applies to.

This article was previously published under Q202025
Moderate: Requires basic macro, coding, and interoperability skills.

For a Microsoft Access 2002 version of this article, see 291054 (http://support.microsoft.com/kb/291054/EN-US/ ) .

↑ Back to the top


Symptoms

If a report or a form has its RecordSource property defined as a table that contains no records, "#Error" is displayed when you preview the report or view the form in Form view if a bound control on the report or form is defined by using the Trim() function.

↑ Back to the top


Cause

When you use an expression to define the ControlSource property for a form or report, Microsoft Access evaluates the expression and presents the result for the control. If Access evaluates a blank field, it displays "#Error."

↑ Back to the top


Resolution

To avoid this error, surround the RecordSource property with an IIF (Immediate If) statement.

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Create a table with two text fields named Field1 and Field2.
  2. Create a report based on this table.
  3. Add the Field1 and Field2 fields to the detail section of the report.
  4. Modify the ControlSource property for the Field1 field as follows:
    =Trim([Field1])
  5. Preview the report. Note that the Field1 field contains #Error and that the Field2 field is blank.
  6. Create a form based on the table.
  7. Add the Field1 and Field2 fields to the form.
  8. Repeat step 4.
  9. View the form in Form view. Note that the Field1 field contains #Error and that the Field2 field is blank.

↑ Back to the top


References

For more information about errors in calculated controls, please see the following article in the Microsoft Knowledge Base:
199355� ACC2000: Valid Sum() Function Returns #Error? in Calculated CTRL
For more information about the Trim() Function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type trim function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB202025, kbusage, kbprb, kberrmsg

↑ Back to the top

Article Info
Article ID : 202025
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 263