Help with On Format code

  • Thread starter Thread starter JohnB
  • Start date Start date
J

JohnB

Hi. I want to have a reports subreport appear only if a
certain field in the subreport has some text content. Can
anyone suggest what the On Format code would look like?
Assume the names are as follows.

Report - rptMain
Subreport - rptSubreport
Field to check for content in rptSubreport - txtContent

Thanks, JohnB
 
Try . .

Having the subreport based on a query that only returns the relevant records
and then add a textbox to your mainreport called for eg txtTitle

In the OnOpen event of rptMain

If Me.nameofrptSubreport.Report.HasData = False Then
txtTitle = "Nothing to report"
Else
txtTitle = "Current Data"
End If

HTH
 
Thanks Newbie. Hmmmm. That's not exactly what I had
intended. I want to control the visability of the
Subreport, based on the txtContent fields content. Your
code seems to produce a message in a text box.
Rearranging your code might work though. How about -

IfNot IsNull Me.rptSubreport.txtContent Then
Me.rptSubreport Visable = True Else
Me.rptSubreport Visable = False
End If

Would that work, do you think? Have I pointed to
txtContent in rptSubreport correctly?

Thanks again, JohnB
 
Back
Top