Sanjay
asked on
VB code to hide/unhide a report's label based on whether or not an embedded subreport does/does not have data to display
How do I write VB code to hide/unhide a report's label based on whether or not an embedded subreport does/does not have data to display.
The name of my embedded subreport is "Child92". Child92 is embedded in my main report's footer. If the subreport has data to display, then I want Label139 to be visible. If the subreport has no data to display, then I want Label139 to not be visible.
I have added the following code below on my main report's open property, but the code is not working properly. At least I have put my logic down on what I am trying to accomplish. Maybe this code should be in my main report's OnFormat event?
Please help....
The name of my embedded subreport is "Child92". Child92 is embedded in my main report's footer. If the subreport has data to display, then I want Label139 to be visible. If the subreport has no data to display, then I want Label139 to not be visible.
I have added the following code below on my main report's open property, but the code is not working properly. At least I have put my logic down on what I am trying to accomplish. Maybe this code should be in my main report's OnFormat event?
Please help....
Private Sub Report_Open(Cancel As Integer)
If Child92.Report.Visible Then
Me.Label139.Visible = True
Else
Me.Label139.Visible = False
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi C:
Thanks so much for the quick responses. Label139 is located in my main report's footer. I will give your recommendation a try and respond back.
Thanks so much for the quick responses. Label139 is located in my main report's footer. I will give your recommendation a try and respond back.
ASKER
Hi C:
Since the Label is in my footer section, I modified your code to reference the footer and it works.
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Label139.Visible = Child92.Report.HasData
End Sub
Awesome. Thanks C.
Since the Label is in my footer section, I modified your code to reference the footer and it works.
Private Sub ReportFooter_Format(Cancel
Label139.Visible = Child92.Report.HasData
End Sub
Awesome. Thanks C.
sxxgupta,
shouldn't { awesome } merit a rating of at least 9 + ;-)
shouldn't { awesome } merit a rating of at least 9 + ;-)
ASKER
Of course. If I had the option of assigning a 10, I would because you have helped me with a lot of past questions and in the process have helped me improved my VBA learning.
Sanjay
Sanjay
private sub nodata(cancel as integer)
Label139.visible=false
end sub