Custom label in subreport

K

Kurt

I have a report with one subreport, linked by ProjectID.

The report shows project information and the subreport
shows a list of tasks assigned to that project.

If there are no tasks in the subreport for that project
(i.e, txtTask is null), the subreport vanishes from the
report. Instead of it disappearing, I would like a label
in the detail section of the subreport to become visible
and read "No tasks have been assigned to this project."

I've tried code in both the On Activate event for the
subreport and the On Print event of the Detail section,
but the subreport still disappears. Should I instead be
putting the code in the main report? (In which case it
would have to refer to the control on the subreport.)

The code I'm using is:

If IsNull(Me.txtTask) Then
Me.lblNoTasks.Visible = True
Else
Me.lblNoTasks.Visible = False
End If

Thanks. Kurt
 
A

Allen Browne

You cannot use the subreport events, since they do not fire when there are
no records.

Place a text box on the main report, with this Control Source:
=IIf([Sub1].[Report].[HasData], Null, "No tasks have been assigned to this
project.")
substituting the name of your subreport control for "Sub1".
 

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