Link to home
Start Free TrialLog in
Avatar of SamB
SamB

asked on

Subreports - transparent background?

Hi Experts,

I have a report that contains numerous sub reports.

A couple of the subreports sometimes contain no data - and are therefore not shown on the main report. This leaves a blank space on the overall report which I would like to fill with the message - "No Data Available".

I had thought the easiest way to do this was to put a label on the main report behind these subreports - so that when the subreport was present the label was hidden - and when it wasn't there it was visible. However, the subreports seem to be "transparent" so that you can always see the label in the background.

Any ideas?

Thanks,

Sam
Avatar of bluelizard
bluelizard
Flag of Switzerland image

actually, with the sections' property "BackColor", you can set white as the background color.  but i think this is the default, and i don't event think it's possible to set it to transparent...  so you probably already have the backcolor set to white, but you still might want to check.

possibly, the ordering of the objects is wrong, i.e., your label "no data available" is *in front* of the subreport instead of *behind* it.  try selecting the label and then choosing Format > Send to back


--bluelizard
This doesn't help your label issue, but I often want the space the subreport occupies to disappear if there is no data in the subreport. I Set the height property of the subreport to 0.001 cm and its can grow property to true and its border property to transparent. The subreport doesn't appear if there's no data , not does it take any space on the parent  report, but appears with the appropriate length wjhen populated. Don't, howver, put the No Dataq Avaialble label below this very short report as it wiull always appear below it.
Avatar of SamB
SamB

ASKER

Hi bluelizard

Thanks for your suggestions - I've tried these but no success - the wierd thing is that some elements of the sub report block parts of the label and some do not. It's as if the label has become part of the subreport?

Kelvinsparks - thanks for your advice - I use this on one part of the report - but on this specific sub report I want to "highlight" the fact that the data is not available.

Sam
one possibility would be to make the label "no data" invisible and use the subreport's "On No Data" event to make it visible.  i don't have any experience with this, but it might be worth a try.


--bluelizard
sorry, forget my last post, i just found this about the OnNoData event in the help:

"This event doesn't occur for subreports. If you want to hide controls on a subreport when the subreport has no data, so that the controls don't print in this case, you can use the HasData property in a macro or event procedure that runs when the Format or Print event occurs."

i'll investigate into this and let you know...


--bluelizard
okay, here we go, i run a small test, and here's how it worked:

(1) place the label on your main report (and set it to visible or invisible, it doesn't matter)

(2) in your *subreport*, go to the event "OnOpen", click on the "..." button and write the following code into the sub that shows up:

    If Not (Me.HasData) Then
      Me.Parent.Controls("MyLabel").Visible = True
    Else
      Me.Parent.Controls("MyLabel").Visible = False
    End If

(of course, you have to replace MyLabel with your label's name, but keep the quotes!)

does that work?


--bluelizard
ASKER CERTIFIED SOLUTION
Avatar of bluelizard
bluelizard
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SamB

ASKER

Thanks Bluelizard,

Your solution works great.

I had also found a rather wierd work around myself - just by changing the subforms back colour from the standard "white" background of "16777215" to something like "16777214" !!!!!!!!!!!

But your code was much more professional!

Thanks again,

SamB