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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error message on expression 1

Status
Not open for further replies.

Brogrim

Technical User
Jul 28, 2000
184
0
0
IE
I am adding the values in 2 sub reports

Value 1
([sbrptROCAttendances1/2].Report![txtAttendances1/2]/2)

Value 2
([sbrptROCAttendancesFull].[Report]![txtAttendancesFull])

The expression is
=([sbrptROCAttendances1/2].[Report]![txtAttendances1/2]/2)+([sbrptROCAttendancesFull].[Report]![txtAttendancesFull])

My problem is that if there is nothing Value 1 or 2 then the expression returns an error message.

 
You need Nz:

[tt]=(Nz([sbrptROCAttendances1/2].[Report]![txtAttendances1/2],0)/2)+(Nz([sbrptROCAttendancesFull].[Report]![txtAttendancesFull],0))[/tt]

The value chosen for null values does not have to be 0, though it seems to suit this case.
 
I'm not confident Nz() will work if there are no records in a subreport. Try something like:
=IIf([sbrptROCAttendances1/2].[Report].HasData,([sbrptROCAttendances1/2].[Report]![txtAttendances1/2]/2),0)+
IIf([sbrptROCAttendancesFull].[Report].HasData,([sbrptROCAttendancesFull].[Report]![txtAttendancesFull]),0)


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks for the answers

dhookom worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top