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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show/hide subreports

Status
Not open for further replies.

melaniecarr23

Programmer
May 2, 2005
79
US
Is there a way to hide a subreport if no records show up in the subquery it's based on? (sort of like trim does for address fields)

I have 8 subreports, and if the dd_query doesn't apply to a patient, I want to hide it so the next subquery shows in its place.

Is there a way to do this?

Thanks! :)
 
Hi
I put this code on a subform, and it seems to work:
Code:
Private Sub Form_Current()
    If Me.RecordsetClone.RecordCount = 0 Then
        Me.Visible = False
    Else
        Me.Visible = True
    End If
End Sub
 
Where on the subform do you put it? My subform is dd_report. Do I actually put it somewhere on the subform or as a module?
 
Hi
Yes, in a module. If you look at the Properties of your subform, you should see On Current on the Events Tab. If you click the three dots and choose Code Builder, a module window should open with this in it:
Code:
Option Compare Database

Private Sub Form_Current()

End Sub
Just fill this:
Code:
    If Me.RecordsetClone.RecordCount = 0 Then
        Me.Visible = False
    Else
        Me.Visible = True
    End If
Into the the Sub. Hope that's a better explanation! :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top