Always show subreport border

L

Larry

I have subreports on my report, that need a border around them. I set
the borderstyle to show, and it works fine, except when there is no
data for the subreport.

Is there a way to get the border to show anyway (so the user will see a
blank box). Having the border always there makes the report look the
same to the user, which is what they want.
 
D

Duane Hookom

In addition to Roger's reply, you can set this box to invisible if there is
data in the subreport. You need to add code to the On Format event of the
report section that contains the subreport.

Me.boxControlName.Visible = (Me.subreportname.HasData = False)
 
L

Larry

Something I learned about last week. It means you dont' take your
laptop with you, you don't answer your cell phone when it's someone
from work and you just do something called "relax".

It's quite an interesting experience.
 
L

Larry

Ok guys, I have started trying to get this to work, but am having a
problem. Maybe I'm trying to be too fancy?

I put the following code in the Detail_Format event:

If Not Me.subrptImpact.Report.HasData Then
With Me.subrptImpact.Report
Me.Line (.Left, .Top)-Step(.Width, .Height), 0, B
End With
End If

But I am not getting a box, the same size and location as the subreport
control, which is what I'm shooting for here. At best, I get a box,
below where the control should be and it changes size slightly, but is
never the right size/location (not even close to location).

I turned off Can Shrink for the subreport, but that did not help
either. I also tried this in Detail_Print, but it made no difference.

I thought this would be a more "eligent" way to do this, but now I may
just go ahead and manually draw boxes (what a shame).

Any ideas?
 
D

Duane Hookom

Nice thought but if there is not data then there might not even be a
subreport control. At the very least, you are not referring to the actual
report. You should reference only the subreport CONTROL.

If Not Me.subrptImpact.Report.HasData Then
With Me.subrptImpact
Me.Line (.Left, .Top)-Step(.Width, .Height), 0, B
End With
End If

I am not convinced that even this will work.
 
L

Larry

DOH!

That's what I get for being lazy and doing a copy/paste from the
previous line. I KNEW I didn't want to reference the report's location,
but the controls location! I can't believe I didn't see that.

Anyway, I removed that to specify the control's location, and it "kinda
sorta" worked, but not well. It always put the new box in the exact
location specified, but since the previous areas could grow/shrink, it
did not move with that and would draw over lower areas of the report.

What I finally decided to do (and this is working) is to use a label,
the exact size and location of each of these subreports, with the
phrase "No Data" in it. Made the borders the right size and invisible.
Basically, what was described earlier with a box, but I liked the NO
DATA notation. This works, but the only problem is that I have to
remember to move the label with the subreport, if the user wants to
move things around.

Oh well, so much for elegent.

Thanks for all the advice.
 

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