?
Solved

Subreports - transparent background?

Posted on 2005-05-11
8
Medium Priority
?
1,243 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:SamB
  • 5
  • 2
8 Comments
 
LVL 14

Expert Comment

by:bluelizard
ID: 13976419
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
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 13976449
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.
0
 
LVL 1

Author Comment

by:SamB
ID: 13976598
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Expert Comment

by:bluelizard
ID: 13977960
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
0
 
LVL 14

Expert Comment

by:bluelizard
ID: 13978055
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
0
 
LVL 14

Expert Comment

by:bluelizard
ID: 13978187
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
0
 
LVL 14

Accepted Solution

by:
bluelizard earned 2000 total points
ID: 13978354
one more correction:  don't put any code into the subreport's "OnOpen" event (this will only have an influence on the NEXT "detail line", which is not what we want here).  instead, go to the section in the main report that holds the subreport (typically the "detail" section), open that section's properties, and put the following code into the OnFormat event:

  If Me.MySubreport.Report.HasData = True Then
    Me.MyLabel.Visible = False
  Else
    Me.MyLabel.Visible = True
  End If

(again: replace MySubreport with the name of the subreport and MyLabel with the name of your label).

now, it should work... (hopefully... i've said so several times before...)


--bluelizard
0
 
LVL 1

Author Comment

by:SamB
ID: 14049679
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
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question