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

[b]Nz & HasData Error[/b]

Status
Not open for further replies.

blindlemonray

Technical User
Nov 24, 2003
130
GB
Hi, I have two total on seperate sub reports and then use them in a calculation with the main report which works fine when there is data in both values. One of the values sometimes has no data and it then creates an error

I have read many of the posts re the above and cannot get it to work.

The two I have tried are
Code:
=sub1.Report!Hours-IIf(sub2.Report!Sum.HasData,sub.Report!Sum,0)

and also
Code:
=sub1.Report!Hours-Nz(sub2.Report!Sum,0)

If anyone can give me some pointers or tell me where I am going wrong it would be much appreciated
 
I wouldn't create a control named "Sum".
Try
Code:
=sub1.Report!Hours-IIf(sub2.Report.HasData,sub.Report!Sum,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]
 
Hi DHookum,

That was just a badly abbreviated version of the whole query.... This is the whole thing:-

Code:
=Totals_sub.Report!Plan_Hours-callers_sub.Report!SumofHours
Code:
=Totals_sub.Report!Plan_Hours-IIf(callers_sub.Report!SumOfHours.HasData,callers_sub.Report!SumOfHours,0)

 
My answer stays basically the same:
Code:
=Totals_sub.Report!Plan_Hours-IIf(callers_sub.Report.HasData, callers_sub.Report!SumOfHours,0)
You check the HasData of the report, not the control.

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]
 
Hi Dhookum,

Thanks for that.. didn't realise about the for the report not the control.

Works a treat.

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top