Report/Subreport Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith Wilby

    Report/Subreport Question

    A97

    I have a report/sub-report setup and for some records in the main report,
    the sub-report is blank. I want to set the height of the sub-report to zero
    where it is blank. I've set all the "Can shrink" properties to 'yes' but
    I'm having trouble with the syntax referencing the text boxes on the sub-
    report.

    I get run-time error 2445 (you entered an expression that has an invalid
    reference to the property form/report) on the first line of this in the
    report's On open event:

    If IsNull(Reports! rptECR!srptECR! txtID) Then
    Me.srptECR.Heig ht = 0
    Me.lblSub.Heigh t = 0
    Me.GroupHeader2 .Height = 300
    Else
    Me.srptECR.Heig ht = 240
    Me.lblSub.Heigh t = 240
    Me.GroupHeader2 .Height = 540
    End If

    I've tried using the "Me" method to reference sub-form objects too but with
    similar results.

    Any suggestions greatfully received.

    Keith.
  • Allen Browne

    #2
    Re: Report/Subreport Question

    Hi Keith

    You cannot use the Report_Open of the subreport like that, but you should
    not need to. Further, you cannot refer to the text boxes on a subreport that
    has no data: they actually don't exist.

    If the subreport has no records, nothing is printed. If the subreport
    control's CanShrink is set to Yes, and the main report's (Detail?) section's
    CanShrink is also Yes, that should be all you need.

    --
    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.

    "Keith Wilby" <keith.wilby@Aw ayWithYerCrap.c om> wrote in message
    news:Xns95426C7 834A2Ckeithwilb y@10.15.188.42. ..[color=blue]
    > A97
    >
    > I have a report/sub-report setup and for some records in the main report,
    > the sub-report is blank. I want to set the height of the sub-report to
    > zero
    > where it is blank. I've set all the "Can shrink" properties to 'yes' but
    > I'm having trouble with the syntax referencing the text boxes on the sub-
    > report.
    >
    > I get run-time error 2445 (you entered an expression that has an invalid
    > reference to the property form/report) on the first line of this in the
    > report's On open event:
    >
    > If IsNull(Reports! rptECR!srptECR! txtID) Then
    > Me.srptECR.Heig ht = 0
    > Me.lblSub.Heigh t = 0
    > Me.GroupHeader2 .Height = 300
    > Else
    > Me.srptECR.Heig ht = 240
    > Me.lblSub.Heigh t = 240
    > Me.GroupHeader2 .Height = 540
    > End If
    >
    > I've tried using the "Me" method to reference sub-form objects too but
    > with
    > similar results.
    >
    > Any suggestions greatfully received.
    >
    > Keith.[/color]


    Comment

    • Keith Wilby

      #3
      Re: Report/Subreport Question

      "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote:
      [color=blue]
      > If the subreport has no records, nothing is printed. If the subreport
      > control's CanShrink is set to Yes, and the main report's (Detail?)
      > section's CanShrink is also Yes, that should be all you need.[/color]

      That's worked a treat, many thanks Allen.

      Comment

      Working...