D
doyle60
I have a report with photographs. If there are fewer than five
photographs to display in a group, I want a subreport to open that has
large photos. If there are five or more photos, I want Access to
switch to another subreport to open that has smaller photos. So the
single report will switch back and forth for the printing, depending on
the count in each section.
I placed a subreport called SelfPrintNew in a section called "GroupID"
and created a text box in the same section that adds up the number of
photos. I called it "CountThem" and put "=Count([StyleNumber])" in the
Control Source, keeping the Running Sum property set to No. (I checked
the results out without the code and it surely works correctly.)
I put this in the OnOpen property of the form:
If CountThem < 5 Then
Me.SelfPrintNew.SourceObject = "Report.SelfPrintNewrpt02sub"
Else
Me.SelfPrintNew.SourceObject = "Report.SelfPrintNewrpt01sub"
End If
Nice try, but it doesn't work. I've done this sort of thing many times
and can't quite figure out what to do correctly. I experimented quite
a lot but can't seem to fall on the solution.
I get the following error:
Run-time error '2427':
You entered an expression that has no value.
The expression may refer to an object that has no value,
such as a form,a report, or a label control.
But it is a value. It is surely not a form or report or label. If I
put a "Me." before the CountThem in the code, the same problem occurs.
When I move the code to the OnPrint of the GroupID section, I get an
error stating that it can't set this after printing has started. But I
pretty much think I need it in this GroupID section for the report to
work as I want it to.
Anyway, what is the best way to handle this? Simply put, if the
records add up to such and such, use this source object, if they add up
to that and that, use that source object.
Thanks in advance,
Matt
photographs to display in a group, I want a subreport to open that has
large photos. If there are five or more photos, I want Access to
switch to another subreport to open that has smaller photos. So the
single report will switch back and forth for the printing, depending on
the count in each section.
I placed a subreport called SelfPrintNew in a section called "GroupID"
and created a text box in the same section that adds up the number of
photos. I called it "CountThem" and put "=Count([StyleNumber])" in the
Control Source, keeping the Running Sum property set to No. (I checked
the results out without the code and it surely works correctly.)
I put this in the OnOpen property of the form:
If CountThem < 5 Then
Me.SelfPrintNew.SourceObject = "Report.SelfPrintNewrpt02sub"
Else
Me.SelfPrintNew.SourceObject = "Report.SelfPrintNewrpt01sub"
End If
Nice try, but it doesn't work. I've done this sort of thing many times
and can't quite figure out what to do correctly. I experimented quite
a lot but can't seem to fall on the solution.
I get the following error:
Run-time error '2427':
You entered an expression that has no value.
The expression may refer to an object that has no value,
such as a form,a report, or a label control.
But it is a value. It is surely not a form or report or label. If I
put a "Me." before the CountThem in the code, the same problem occurs.
When I move the code to the OnPrint of the GroupID section, I get an
error stating that it can't set this after printing has started. But I
pretty much think I need it in this GroupID section for the report to
work as I want it to.
Anyway, what is the best way to handle this? Simply put, if the
records add up to such and such, use this source object, if they add up
to that and that, use that source object.
Thanks in advance,
Matt