Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Border around subreport and record it equals on the main report 1

Status
Not open for further replies.

jw5107

Technical User
Jan 20, 2004
294
US
I have a report that has a subreport as well. Is there a way to put a border around the subreport and the record it equals (via the link between main and sub)?? The subreport is only visible when it equals the record on the main.
Is there any example databases out there that I can use?

Thanks,
jw5107
 
I don't understand what you are asking. Do you want a rectangle to be display in your main report even if there are no matching records returned in your subreport?

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
dhookum,

I want a rectangle to be displayed only when there IS matching records in the subreport.

jw
 
I just created a report with a subreport and if there are not any matching records in the subreport, there is no rectangle/border displayed.
I don't know why your border would display if there are no matching records.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Dhookum,

Oh man - I think we are both confused now!!!!

I have a main report with a subreport in the detail section. The subreport use a field as the linking master & child field. When the records match, the subreport is visible on the main report. Not by anything I have done in code behind the report - it just works that way.

I was just wondering if a border or rectangle can be displayed around the main form record and the matching subreport record(s). The report works fine the way it is, it just some formatting issues that I am trying develope in order to make the report more user friendly.

jw
 
I assume by "main form record" you mean main report record.
Do you want a dynamically sized rectangle around your detail section on your main report? If so, you can use code like:
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Me.Line (0, 0)-Step(Me.Width, Me.srptOrders.Top + Me.srptOrders.Height), , B
End Sub
You would need to substitute your subreport control name in the code.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
dhookum,

yeah your right - I meant main report record.

What do you mean by "dynamically sized" rectangle. I tried your suggestion, and it gave me a thin rectangle the width of the detail section in between each record on the main report in the detail section. I would like the rectangle to be only where the subreport appears. Around the subreport - around the main report record that it matches.

jw
 
I still don't understand what you mean by "Around the subreport - around the main report record that it matches." Do you want a rectangle around the subreport object or the main report record or where?

You should be able to modify the code I provide to create a rectangle almost anywhere in the detail section. Dynamically sized means that if the subreport gets bigger, the rectangle will get bigger.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
dhookum,

I guess on the main report where the subreport matches. Right now the code you provided put a rectangle around every record on the main. Even where the subreport matches. I would like for the rectangle to appear only when the subreport matches.
Is this possible??
thanks for your help!!
jw
 
By "subreport matches" I assume you mean the subreport contains records. I also assume your third sentence should have been "Even where the subreport doesn't match."

If you don't want a rectangle if the subreport contains no records then use code like:
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    If Me.srptOrders.Report.HasData Then
        Me.Line (0, 0)-Step _
            (Me.Width, Me.srptOrders.Top + Me.srptOrders.Height), , B
    End If
End Sub

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Dhookum,

Perfect!! This is exactly what I am wantin'!!! Thank you very much.

2 more questions:
Is there a way to change the line weight to a heavier/darker line?

How can I make this work the same way if a subreport is in a footer? I have some groupings involved in a report and the best place to put the subreport is in the one of the footers. This is the same scenario, just a different formatted report..

Thanks again!! STAR FOR YOU!!
jw
 
You can set the DrawWidth in the code
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Me.DrawWidth = 10
    If Me.srptOrders.Report.HasData Then
        Me.Line (0, 0)-Step _
            (Me.Width, Me.srptOrders.Top + Me.srptOrders.Height), , B
    End If
End Sub
You can use similar code in the On Format event of any section.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Dhookum,

Great this - once again, is exactly what I was after!!!

What would be the "similar code" to use if the subreport is in a footer of a group on a report?
 
You would open the code window for the group footer and use the same code. Make sure the subreport control name is correct for your needs.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top