Custom label in subreport

  • Thread starter Thread starter Kurt
  • Start date Start date
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
 
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".
 
Back
Top