A report, with a subreport, has an "On Print" event to the MainReport. Then
"Run-Time Error "2427": You entered an expression that has no value. ",
appears and on "Debug" the code line: "If
Left([Reports]![MainReport]![SubReport].[Report]![Course#],1)=”8” Then" is
highlighted. The "Help" button brings up a blank screen. The source for both
forms has data. What is the cause and fix? The coding is as follows:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Left([Reports]![MainReport]![SubReport].[Report]![Course#],1)=”8” Then
Reports!MainReport!SubReport.Report!SupplyFee=0
Else
Reports!MainReport!SubReport.Report!SupplyFee=20
End If
If there are no records to print in a subreport for the record in the main
report, Access prints nothing for the subreport. If you code tries to refer
to the text box in the subreport, it does not exist, and so your code
generates an error.
To avoid that, test the HasData property of the subreport before referring
to the controls:
With Me.[SubReport].Report
If .HasData Then
If ![Course#] = "8" Then
!SupplyFee = 0
Else
!SupplyFee = 20
End If
End If
End With
It might be easier to use this as the Control Source for SupplyFee text box
in the subreport, with no code needed:
=IIf([Course#]="8", 0, 20)

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>A report, with a subreport, has an "On Print" event to the MainReport. Then
> "Run-Time Error "2427": You entered an expression that has no value. ",
[quoted text clipped - 9 lines]
> Reports!MainReport!SubReport.Report!SupplyFee=20
> End If