Further help with code please

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

JohnB

Hi. I posted this a few days ago and Newbie initially
replied but has now gone quiet. Can anyone else help
please?

I want to control the visability of a reports
Subreport, based on the content of a field called
txtContent, which is in the Subreport. I think something
along the lines of the code below, used in an On Format
event, should do but I cant get the syntax right.

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

The problem is the first line, where Im trying to test
for content in the field in the subreport.

Can anyone help me get this code to work? Thanks, JohnB
 
IsNull is a function: its argument needs to be in parentheses:

If IsNull(Me.rptSubreport.txtContent) Then
Me.rptSubreport Visible = False
Else
Me.rptSubreport Visible = True
End If

(You also misspelled Visible)
 
Thanks Doug but theres still a problem. First I had to
modify the Me lines - seems it needs a full stop in
there. Now Im getting Run Time Error 438 - Object doesnt
support this property. When I look at the code, the top
line is highlighted in yellow. My code currently stands
as follows

If IsNull(Me.rptSubreport.txtContent) Then
Me.rptSubreport.Visible = False
Else
Me.rptSubreport.Visible = True
End If

Can you see whats wrong? Is there a better way of doing
this? Thanks again, JohnB
 
Try If IsNull(Me.rptSubreport.Report.txtContent) Then

Microsoft made the (unfortunately, in my mind) decision to name the
container for the subreport the same as the subreport contained within it.
That often leads to confusion.
 
Back
Top