Help with On Format code

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
 
N

Newbie

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
 
J

JohnB

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top