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!

Display textbox control in subreport when it has No Data

Status
Not open for further replies.

Luzbel

IS-IT--Management
Apr 20, 2007
45
PR
In a subreport I created a sub on detail_format event that will display a text when there is no data returned.

Code:
‘Code in sub-report
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.Report.HasData Then
    Me.Label43.Visible = True
    Me.txtNotEntered.Visible = False
Else
    Me.Label43.Visible = True
    Me.txtNotEntered.Visible = True
End If

End Sub

It works fine on the subreport when run alone. When I run the main report it doesn’t trigger.

I added the same code in the main report to see if it would work. It runs through the lines of code but still cannot see the txtNotEntered textbox control.

Code:
‘Code in main report
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me!rptResults_Comments.Report.HasData Then
    Me!rptResults_Comments.Report.Label43.Visible = True
    Me!rptResults_Comments.Report.txtNotEntered.Visible = False
Else
    Me!rptResults_Comments.Visible = True
    Me!rptResults_Comments.Report.Label43.Visible = True
    Me!rptResults_Comments.Report.txtNotEntered.Visible = True
End If

End sub

I am using MS Access 2003.
 
If a subreport doesn't return any data, then don't expect anything to be available in the subreport. Your code in the main report could set properties of controls in the main report.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top