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

Hiding Subreports on no data

Status
Not open for further replies.

sera

Technical User
Jun 29, 2000
360
US
Does anyone know how to hide a subreport when there is no data in the subreport?
Sera
 
Anytime I've ever used a subreport it disappears automatically if there is no data to report on. Are you using an unbound subreport? Joe Miller
joe.miller@flotech.net
 
nope! The subforms are bound to subreports. I don't get any data if there isn't any. I do have labels in the subreports that print no matter what. I could move the labels out into the main report. Basically what I am trying to do is fit all of the information in one report on one page. The particular subforms that I am trying to hide do not have data most of the time, so if I could hide them when there is no data I can save some space.
Sera
 
You know what...I can't move the labels into the main report because then that defeats the purpose of what I am trying to do. I don't even want it to look like those subreports exist if there is no data in them. I hope I am not confusing you.
Sera
 
My report has labels as well and a report header so that I can print them standalone if desired, they disappear when printed as a subreport. What section are the labels placed in? I have labels in the Page Header and the Report Header only, maybe that makes a difference? Joe Miller
joe.miller@flotech.net
 
I also only have labels in the report header. Are you using Access 2000? I am using 97. Maybe that is the difference.
Sera
 
You know what else...in each subreport I have an unbound textbox that is tied to a function. I use this function to output all of the records in a comma delimited line. Maybe this has something to do with the reason that my subreports are not disappearing automatically. I will post the code...
Function BlendTheData(strSQL As String) As String
On Error GoTo Err1
Dim Rs As Recordset, Db As DATABASE, fld As Field
Set Db = CurrentDb()
Set Rs = Db.OpenRecordset(strSQL, dbOpenSnapshot)
For Each fld In Rs.Fields
BlendTheData = fld.Value
Next
Rs.MoveNext
Do Until Rs.EOF
For Each fld In Rs.Fields
BlendTheData = BlendTheData & ", " & fld.Value
Next
Rs.MoveNext
Loop
Exit1:
Exit Function

Err1:
MsgBox Err.Number & " " & Err.Description, vbInformation, "Sera is Dumb..."
Resume Exit1
End Function

I am pretty new at writing code in Visual Basic. But maybe you can see something I am not seeing...I wasn't trying to stump you...
Sera
 
do the commas appear when you run the report? If they are appearing then you need to test for only commas (IE: no records) and set your string to "" in your code. Joe Miller
joe.miller@flotech.net
 
No the commas are not appearing when I run the report. When I run or print the report all I get is the label that appears in the report header.
Sera
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top