Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculated Controls

Status
Not open for further replies.

GiovanniB

Programmer
Jul 16, 2001
3
US
Hi,

I am confronting a problem on a query report that displays the difference of two fields by a calculated control where one field is blank. This gives me the typical '#error' in the field when report is viewed.

example: Diff: <Functionname>([Field1],[Field2])

Of course, it is impossible to allow such output to show on a report. Therefore, how can I subsitute whenever '#Error' occurs with another value such as 'Info n/a' or such without using 'Is Not Null' in the Criteria.

Thanks in advance for any assistance.

Gio.
 
You may try this:

***

on error go to eh

dim strValue as string

strValue=cstr(<Functionname>([Field1],[Field2]))

txtField=strValue

exit sub

eh:

txtField='Info n/a'

***

txtField is the field you got &quot;#error&quot; in the report before.

Hope this helps.

Seaport
 
You can also test the outcome of your function with the IsError which returns a true/false if the expression/field/equation/etc.. is an error.

iif(IsError(MyFunction(1,2)),&quot;N/A&quot;,MyFunction(1,2))

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top