how do I access data on subreport to use in calculation on main re

S

SuzyQ

I have a subreport that show hours authorized and in the main report I have
hours billed. I want to have a calculated field in the main report that
shows the percentage of billed/authorized. I've tried acccessing the
subreport field using report.[reportname].[fieldname] but when I run the
report it doesn't know what that field is and displays a textbox for data
entry. How can I access the field in the subreport to do the calculation I
need?

Thanks for any help in advance.
 
S

SuzyQ

I actually got this to almost work. I had the subreport name aliased in the
report. Now this works as long as the subreport has data, but when it does
not have data I get a message that I tried to access an object with that does
not have a value. How can I test ahead of time if the subreport field has
value?
 
M

Marshall Barton

SuzyQ said:
I have a subreport that show hours authorized and in the main report I have
hours billed. I want to have a calculated field in the main report that
shows the percentage of billed/authorized. I've tried acccessing the
subreport field using report.[reportname].[fieldname] but when I run the
report it doesn't know what that field is and displays a textbox for data
entry. How can I access the field in the subreport to do the calculation I
need?


It really isn't there when a subreport has no records. Use
this kind of expression to guard against the situation:

=IIf(subreport.Report.HasData, [hours billed] /
subreport.Report.[horus authorized], 0)
 
S

SuzyQ

worked perfectly... thanks

Marshall Barton said:
SuzyQ said:
I have a subreport that show hours authorized and in the main report I have
hours billed. I want to have a calculated field in the main report that
shows the percentage of billed/authorized. I've tried acccessing the
subreport field using report.[reportname].[fieldname] but when I run the
report it doesn't know what that field is and displays a textbox for data
entry. How can I access the field in the subreport to do the calculation I
need?


It really isn't there when a subreport has no records. Use
this kind of expression to guard against the situation:

=IIf(subreport.Report.HasData, [hours billed] /
subreport.Report.[horus authorized], 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top